(+84) 463.28.7979

How to Display Recent Posts From A Specific Category In WordPress


For advance users who want to display recent posts from a specific category, we have this article specially for you. Beginner users will most likely not use this. This tutorial is mostly used in creating magazine style themes.

<?php
query_posts(’showposts=1&cat=3′);
while(have_posts()) : the_post();
?>
<ul>
<li><h3><a href=”<?php the_permalink() ?>” rel=”bookmark”><?php the_title(); ?></a></h3>

<ul><li><?php the_content(); ?></li>
</ul>
</li>
</ul>
<?php endwhile; ?>

At the top where it says showpost= change the number to how many posts you want to display, and cat=3 is the id of the category, so change the ID of the category to pick which category will you be displaying.

A live example of this tutorial in action is at Balkhis.com

The news style format where it displays recent news from each category is accomplished using the code above.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>