Home / category / List recent posts from a single category
  • How to List recent posts from a single category

    list-recent-posts-from-a-single-category

    Adding this snippet to your wordpress theme will display the five most recent posts from a single category. Be sure to change the category name CATNAME to the category you wish to display.

    ( click code to copy )

    wordpress snippet : PHP

    <>
    <?php query_posts('category_name=CATNAME&showposts=5'); ?>
    <?php while (have_posts()) : the_post(); ?>
            <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
    <?php endwhile; ?>
    

    ( WordPress codex functions, hooks, in this snippet. )

    the_title, the_permalink, query, have_posts, the_post, _n, query_posts, wp,