Displaying the most recent posts from a single category in WordPress

Have you ever seen a site that showed the most recent post or posts from a single category? If you want that functionality for your own site it's just a small chunk of code.

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


All you need to do is change the ID for the category to the ID that you want to show posts from by changing cat=3. You can also change the number of articles being shown to any number you want by changing showposts=1 to a different number.

This would work well by creating your own custom page to show it on.
  • 1 Users Found This Useful
Was this answer helpful?

Related Articles

Deleting post revisions from the WordPress database

One of the great features the WordPress added in was post revisions. Any changes made to posts...

How do I disable automatic updating in WordPress?

One of the many features added to WordPress in 3.7 was automatically updating for minor releases....

Recovering from the dreaded "eval(gzinflate(base64_decode" attack

So you're running a WordPress site and one day you realize that your search engine traffic is...

I am getting an error when trying to upload media in WordPress.

If you are having problems uploading media to your WordPress installation, it is possible that...

WordPress timing out when posting an article

If WordPress is timing out when you are attempting to post a new article or update an existing...