Blogging Underground- Top Traffic Ranking System Check Here
  Share

Display Recent Post from a Specific Category in wordpress

by Bilal Ahmad on November 5, 2009

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. Display Recent Post from a Specific Category in wordpressYou 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.


Previous Posts by Bilal Ahmad
Related Posts:
  1. Display Random or Rotating Images in wordpress Header
  2. Insert Adsense Code Inside Single Post In WordPress Thesis Theme
  3. Display Adsense Ads Below Nav Bar in TechMaish WordPress Theme
  4. Display Sticky Header Bar In WordPress Blog Using CSS Code
  5. How to Add Signature Under Blogger and WordPress Post

{ 2 comments… read them below or add one }

Blogsolute November 11, 2009 at 1:46 pm

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.

Reply

Chand November 11, 2009 at 1:58 pm

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.

Reply

Leave a Comment

 

Previous post:

Next post: