≡ Menu

Display Recent Post From a Specific Category in WordPress

In some cases you may want to display recent posts in your blog from specific categories. For example if you have a category with a name “Technology” then copy the following code and past in your function.php file. If you are using thesis theme, then make sure to add thesis_hook call for the placement of the recent posts.


If you are using any other wordpress theme, then go to the Appearance>Editor and single.php file and place the code.

while(have_posts()) : the_post();
<li><h3><a href=”<?php the_permalink() ?>” rel=”bookmark”><?php the_title(); ?></a></h3>
<ul><li><?php the_content(); ?></li>
<?php endwhile; ?>

Make sure to change the values in Showposts=1 and Cat=3.

Where showposts = The number of post to be displayed


Cat= 3 is the ID of the Category.

You can find the ID of a specific category from your Dash Board – Post – Category. Place the mouse on a category, and you will see ID for that Category. Just look at to the below screen shot.display recent post 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.