How to list posts by category

by Romy on February 3, 2009

in Tips, Techniques & How-to's, WordPress Plugins

If your website has very good articles, chances are you wanted to get extra mileage for those articles. And it is truly a shame and a waste  if you cannot share them.

The question is, without manually listing and manually updating your list, how do you separately list those articles from the rest of your posts so that they stand out.

I found two plugins that you may find useful. The plugins have their own special features like time stamping, list sorting, etc. So your choice depends on which features you want to use in your site.

I did try them out and they worked fine, except that they require time for setting configurations.

But if what you wanted is only a straightforward list of posts for one or two categories which you want to place in your post template or in a sidebar, then you could just use the database query built into WordPress.

Here’s a sample code which I used to extract and line up the latest posts from any category:

<h2>List of Posts Under Category</h2>
<?php $recent = new WP_Query(“cat=ID&showposts=x”); while($recent->have_posts()) : $recent->the_post();?>
<ul>
<li><a href=”<?php the_permalink() ?>” <?php the_title(); ?></a></li>

Other suggested articles

[Not necessarily related to above post; Automatically generated]

{ 3 comments… read them below or add one }

det February 21, 2009 at 2:55 am

I tried both in a Page and Post. The Plugin’s are activated properly.

They simply displays

Reply

det February 21, 2009 at 3:02 am

It is working now. With Copy/Paste, the “<!-- postsbycategory -->” was put into the Html.

Reply

Romy February 21, 2009 at 11:03 am

det – Glad you were able to get that working.

Reply

Leave a Comment

Previous post:

Next post: