Advertisement
alchymyth

all cats all posts

Apr 7th, 2011
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.70 KB | None | 0 0
  1. <?php  $cats = get_categories('orderby=count&order=DESC');
  2. // http://codex.wordpress.org/Function_Reference/get_categories
  3.  
  4. foreach ($cats as $cat) :
  5.  
  6. $args = array(
  7. 'posts_per_page' => -1, // max number of post per category
  8. 'category__in' => $cat->term_id
  9. );
  10. query_posts($args);
  11.  
  12.      if (have_posts()) : ?>
  13.      
  14.      <h2 id="cat-<?php echo $cat->slug; ?>>">Category '<?php echo $cat->name; ?></h2>
  15.      
  16.      <?php while (have_posts()) : the_post(); ?>       
  17.  
  18.     WHATEVER YOU WANT TO SHOW PER POST - PROBABLY COPY THE CONTENT OF THE LOOP FROM INDEX.PHP
  19.  
  20.     <?php endwhile; ?>
  21.        
  22.     <?php else :
  23.         echo '<h2>No Posts for Category '.$cat->name.'</h2>';              
  24.      endif;
  25.      
  26.      wp_reset_query();
  27.    
  28. endforeach; ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement