Advertisement
alchymyth

cat list and posts

Mar 10th, 2011
388
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.60 KB | None | 0 0
  1. <?php  $cats = get_categories('orderby=count&order=DESC');
  2. // http://codex.wordpress.org/Function_Reference/get_categories
  3.  
  4.  
  5. foreach ($cats as $cat) :
  6.  
  7. echo $cat->name;
  8.  
  9. $args = array(
  10. 'posts_per_page' => -1, // max number of post per category
  11. 'cat' => $cat->term_id
  12. );
  13. query_posts($args);
  14.  
  15.      if (have_posts()) :
  16.      
  17.      while (have_posts()) : the_post(); ?>     
  18.  
  19.     <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a>              
  20.  
  21.     <?php endwhile; ?>
  22.                    
  23.      endif;
  24.      
  25.      wp_reset_query(); ?>
  26.    
  27. <?php endforeach; ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement