WordPress – Display the most Recent Post from a Specific Category

Did you see sites with a magazine style theme who are displaying posts from a specific category. Sometimes only the most recent post.

Well you can do this too easily.

<?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; ?> 

Add the above code anywhere you like in the template.
Make sure you change the category ID and you can change the number of posts displayed as well if you want.

Leave a Reply

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

*