In my previous post I told about SEO for wordpress, Where i told you that it is very necessary to setup the structure of your blog in such a way that user can easily navigate your blog using categories. This will make your blog SEO friendly. Now in this post I want to share that how can we display recent post only from specific category.
Let say you want to show only those Post which are publish in Adsense category.
Ok then Copy this code and paste it where you want to show the recent post from specific category.
<?php
query_posts(’showposts=1&cat=3′);
while(have_posts()) : the_post();
?>
<ul>
<li><h3><a href=”<?php the_permalink() ?>” rel=”bookmark”><?php the_title(); ?></a></h3>
<ul><li><?php the_content(); ?></li>
</ul>
</li>
</ul>
<?php endwhile; ?>
Make sure to change the values in Showposts=1 and Cat=3.
Where showposts = Number of post to be displayed
and
Cat= 3 is the ID of the Catogory.
You can find the ID of a specific category from your Dash Board – Post – Category
Put the mouse on a category, and you will see ID for that Category. Just look at to the below screen shot.You can see in the screen shot that ID for Adsense Category is 12. Similarly you can also find ID for other categories.
Change the ID and save the file.
That’s it.
- Is Social Networking Marketing Helpful for Each Business?
- Five Methods of Becoming More Valuable to Your Social Networking Audience
- Invoicera- An Extraordinary & Cost-Effective Solution To Tackle Your Invoicing Requirements Effortlessly
- Blunders you Need to Avoid In an Email Marketing Campaign
- Things to Lookout for When Finalizing Topics For Guest Blogging




{ 2 comments… read them below or add one }
Yep, If coding seems difficult to any of the users, there is a plugin called “Related Posts by Category” which show posts from specific category and moreover, it detects the category of article and shows from the same, unlike mentioning category ID as stated here.
Well if a single and simple code can do this, then why overloading your blog with allot of Plugins.
It is better to try CSS not Plugins.
Thanks for your comment.