As you know we use :
<h2>Recent Posts</h2>
<ul>
<?php get_archives('postbypost', 6); ?>
</ul>
to show our recent posts. But how do we show recent posts from specific category ?
To do this we use :
<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>
here cat=1 is our category ID number and showposts=10 is our recent posts from specific category count. When you add this code to your sidebar.php file, you have to check your specific category ID from you admin panel, manage, categories.

Posted in
Tags: 

