How to display most recent post from a category

Use following code for showing the recent post from category:

<?php
query_posts(‘showposts=1&cat= get_cat_id(‘category_name’)');
while(have_posts()) : the_post();
?>
<h3><a href=”<?php the_permalink() ?>” rel=”bookmark”><?php the_title(); ?></a></h3>

<?php the_content(); ?>
<?php endwhile; ?>

You can replace the category_name to your category name

You may like following Articles!

16 thoughts on “How to display most recent post from a category

  1. This doesn't seem to be working in the latest version of wordpress. It was giving me a blank page until I removed the quotes around the category name, and then it was simply returning every post instead of just that category. Anyone know who to make this work?

  2. Nice post! You truly have a wonderful way of writing which I find captivating! I will definitely be bookmarking you and returning to your blog. In fact, your post reminded me about a strange thing that happened to me the other day. I’ll tell you about that later…

  3. Nice post! You truly have a wonderful way of writing which I find captivating! I will definitely be bookmarking you and returning to your blog. In fact, your post reminded me about a strange thing that happened to me the other day. I’ll tell you about that later…

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>