How to display (show) Recent Posts from WordPress single category

Advertisements:

How to display (show) Recent Posts from WordPress single category. Here you will learn how to display or show recent posts from a specific WordPress category only.

recent posts wordpress category

Follow the following steps to show recent posts from a specific WordPress category:

1. Login to your wordpress blog

2. Go to Posts >> Categories

3. Check the ID of your Category you want to display (one easy method to check ID is hover the mouse on the category and see the status bar below, at the end you have something like cat_ID=45, here in this example ID is 45)

4. Copy the below code and paste it where you want to display the recent posts (i.e. in sidebar or middlebar)

<ul>
<?php $recent = new WP_Query(“cat=1&showposts=10″); while($recent->have_posts()) : $recent->the_post();?>
<li><a href=”<?php the_permalink() ?>” rel=”bookmark”>
<?php the_title(); ?>
</a></li>
<?php endwhile; ?>
</ul>

5. In the above code change cat=1 to your category number, and showposts=10 specifies how many posts you want to display (in this code it will show 10 recent posts)


Wordpress

No comments yet.

Leave a Reply