Display Posts from Particular Category in WordPress

 

What to display recent posts from a particular category in WordPress blog? Then you are right place.In this article I will show how to display posts in sidebar only from one category.First know How To Get Category ID for a Category Page In WordPress Blog.This category ID must be known to show posts on that category.

Now add the following code in Sidebar.php page,
<h2>Linux Posts</h2>
<?php $recent = new WP_Query(); ?>
<?php $recent->query(‘cat=19&showposts=5‘); ?>
<?php while($recent->have_posts()) : $recent->the_post(); ?>
<ul>
<li>
<a href=”<?php the_permalink(); ?>”>
<?php the_title(); ?>
</a>
</li>
</ul>
<?php endwhile; ?>
Note:
After getting your category Id you can coustamize the code,
<?php $recent->query(‘cat=19&showposts=5‘); ?>
Parameter cat indicates which category’s posts are shown. Parameter showposts is the number of posts to be displayed.
It’s very simple without using any plugin.Isn’t it? ;)

Popularity: 1% [?]

Related posts:

  1. How To Display A Tag Cloud On Your WordPress Blog
  2. How To Get Category ID for A Category Page In WordPress Blog
  3. How to show related posts in wordpress without plugin
  4. Add Google Buzz Button to Your WordPress Blog Posts
  5. Display Random Posts Without WordPress Plugin

Subscribe to receive more Adsense, SEO,Blog Hacks articles to your Inbox

Share this Post:
Digg Google Bookmarks reddit Mixx StumbleUpon Technorati Yahoo! Buzz DesignFloat Delicious BlinkList Furl

No Responses to “Display Posts from Particular Category in WordPress”

Leave a Reply:

Name (required):
Mail (will not be published) (required):
Website:
Comment (required):
XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">

CommentLuv badge

Spam protection by WP Captcha-Free