Return to Snippet

Revision: 14514
at June 5, 2009 21:26 by rocktronica


Initial Code
<?php $categories = get_categories("child_of=17"); foreach ($categories as $cat) { ?>
	<div class="genre_subcat">
		<?php query_posts("cat=$cat->cat_ID&showposts=-1&order=ASC&orderby=name"); ?>
		<h2><?php single_cat_title(); ?></h2>
		<small><?php echo category_description($cat->cat_ID); ?></small>
		<?php while (have_posts()) : the_post(); ?>
			<div class="post">
				<h3><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to
				<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h3>
				<p class="postdate"><?php the_time('F jS, Y') ?></p>
				<?php the_content(); ?>
				<p class="postmetadata">Posted in <?php the_category(', ') ?> |
				<?php comments_popup_link('No Comments', '1 Comment', '% Comments'); ?></p>
			</div>
		<?php endwhile; ?>
	</div>
<?php }?>

Initial URL
http://iamnotagoodartist.com/2009/03/wordpress-how-to-sort-category-archive-posts-by-subcategory/

Initial Description
This code replaces a normal category template. It sorts all posts by their category/subcategory instead of bunching them all together and ordering them by date.  A bit complicated to explain in a box this size... Check the link for a run through!

Initial Title
Organize WordPress Category Archive Listing by Subcategory

Initial Tags
sort, list, wordpress, category

Initial Language
PHP