Most recent post from a specific category – WordPress Theme How to


 
<?php query_posts(’showposts=1&cat=1′); 
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_limit(300); ?></li>
</ul>
</li>
</ul>
<?php endwhile; ?>

another solution for multiple categories

 
<?php
//get 5 recent posts for categories 14 and 9
    $args=array(
      'category__in' => array(14,9),
      'showposts'=>5,
      'caller_get_posts'=>1
    );
    $my_query = new WP_Query($args);
    if( $my_query->have_posts() ) {
      echo '5 recent Posts';
      while ($my_query->have_posts()) : $my_query->the_post(); ?>
        <p><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
       <?php
      endwhile;
    } //if ($my_query)
  wp_reset_query();  // Restore global post data stomped by the_post().
?>

2 thoughts on “Most recent post from a specific category – WordPress Theme How to

  1. Pretty good post. I just came by your blog and wanted to say that I’ve really enjoyed reading your blog posts. In any case I’ll be subscribing to your feed and I hope you write again soon!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s