showing wordpress recent posts from specific category
|
Most of us are suffering for this issue! In our wordpress websites there are many plugins for showing recent posts, with out plugins also we can show by adding some php tag lines, it will shows the all recent posts from our wordpress blog, what if you want to show the recent posts from the particular category !, yes hear is the simple solution for showing recent posts from specific category, its simple,
Upto now we are using this script to showing recent posts:
<h2>Recent Posts</h2>
<ul>
<?php get_archives(‘postbypost’, 6); ?>
</ul>
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.
Friends i hope you success with this small code . If you need a help, just contact us or comment, we will help you soon.
You May Also Like
Get Updates:
| |










