0
votes

I have this plugin in Wordpress that I've heavily modified. The purpose of the plugin is originally to display thumbnails for whatever category you tell it to. As of right now, I've made it done much more than that. But anyways, here is the shortcode for the plugin..

[categorythumbnaillist 7]

7 being the category ID of course. The plugin gets the posts for whatever category and orders them using this code:

$myposts = get_posts( 'numberposts=-1&&category='.$listCatId[1].'&&orderby=
'.$categoryThumbnailList_OrderType.'&&order='.$categoryThumbnailList_Order );

Now, I wanted the plugin to only show posts if it has has the tag "news" in it. So I did the following:

$args=array(
          'tag' => 'news',
          'showposts'=>5,
        );
$myposts = get_posts( $args );

This sucesfully displays 5 posts if it has the "news" tag in it. But here is the problem...

I'm going to be using this plugin multiple times on one page. So when I use the shortcode listed above with a different category ID, the plugin doesn't work since I'm not linking the shortcode category ID with the $myposts code. :(

I'm going to be using the plugin with my news category, photos category and audio category. I would like it to display each categories thumbnails via shortcode (like the plugin is intended to do) but also only display the news posts with the tags "news"... for only the news category. How would I combine my two codes to make it function properly and display only news posts with the tag "news" while still displaying the other category posts properly... all via shortcode like the plugin is supposed to do? So for example... I'd have..

[categorythumbnaillist 3] (news category)
[categorythumbnaillist 5] (photos category)
[categorythumbnaillist 7] (audio category)

I'd like news to only display news posts with the tag "news", photos to display the photos category posts and audio to display the audio category posts. Again, I've already figured out how to do one or the other, I just don't know how to make the code do both.

Any help would truely be appreciated!!! :)

1

1 Answers

0
votes

Please use below code or plugin

<?php
 $postslist = get_posts('numberposts=5&orderby=date&tag=heresthetag');
 foreach ($postslist as $post) :
    setup_postdata($post);
 ?>

 <?php $the_image = get_image(); ?>
    <div class="newspage" <?php if($the_image != "") { ?> style="min-height:5.00em;" <?php } ?>>
<?php if($the_image != "") {?>
        <div class="newspage-img"><a href="<?php the_permalink() ?>"><?php echo $the_image; ?></a>
        </div>
            <div class="newspage-content"><?php }  else {?><div class="newspage-content" style="padding-left:0;"><?php }?>
            <h3 id="post-<?php the_ID(); ?>"><a href="<?php the_permalink() ?>" rel="bookmark" title="Continue reading <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h3>
                <div class="entry">
                <?php the_excerpt() ?>
                <p><span class="read_more"><a href="<?php the_permalink(); ?>">Read more...</a></span> <span class="feedback"><?php comments_popup_link('0 Comments', '1 Comment', '% Comments'); ?></span></p>
                </div>
            </div>
    </div>
 <?php endforeach; ?>

Plugin - http://wordpress.org/extend/plugins/posts-by-tag/