showing wordpress recent posts from specific category

by  $ivateja (223) on August 27, 2009   |   Leave a Comment | 679 views


str wprecentpostsbycataMost 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:
Enter your email :
     
    For getting updates directly to your mobile inbox Click Here



Speak Your Mind

Tell us what you're thinking, If you want a pic to show with your comment, go get a gravatar !






Search:


strPro Plus WP Theme [$71.36]

Buy this Highly adsense Optimised
Wordpress Theme - Increase Your
Adsnese Income Up To 200%



Contact us: strkgroups@gmail.com
Contributers:

» sivateja
» Jaswanth

[ Total of 309 posts by Feb 09, 2012 ]

wordpress visitors