Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php $cats = get_categories('orderby=count&order=DESC');
- // http://codex.wordpress.org/Function_Reference/get_categories
- foreach ($cats as $cat) :
- $args = array(
- 'posts_per_page' => -1, // max number of post per category
- 'category__in' => $cat->term_id
- );
- query_posts($args);
- if (have_posts()) : ?>
- <h2 id="cat-<?php echo $cat->slug; ?>>">Category '<?php echo $cat->name; ?></h2>
- <?php while (have_posts()) : the_post(); ?>
- WHATEVER YOU WANT TO SHOW PER POST - PROBABLY COPY THE CONTENT OF THE LOOP FROM INDEX.PHP
- <?php endwhile; ?>
- <?php else :
- echo '<h2>No Posts for Category '.$cat->name.'</h2>';
- endif;
- wp_reset_query();
- endforeach; ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement