Advertisement
alchymyth

Untitled

Apr 13th, 2011
1,227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.49 KB | None | 0 0
  1. <?php  $cats = array(17, 31, 5); //the category ids
  2.  
  3. foreach ($cats as $cat) :
  4.  
  5. $args = array(
  6. 'posts_per_page' => 2, // max number of post per category
  7. 'category__in' => array($cat->term_id)
  8. );
  9. query_posts($args);
  10.  
  11.      if (have_posts()) :
  12.      
  13.      echo $cat->name;
  14.      
  15.      while (have_posts()) : the_post(); ?>     
  16.  
  17.             <!--post output as usual-->
  18.  
  19.         <?php endwhile; ?>
  20.        
  21.     <?php else :
  22.     echo 'No Posts for ' .$cat->name;              
  23.      endif;
  24.      
  25.      wp_reset_query(); ?>
  26.    
  27. <?php endforeach; ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement