Forums

A category page with an alphabetical list of subcategories? (2 posts)

  1. anesthezea
    Member
    Posted 1 month ago #

    I have a book blog and I'd like to set up a category page such as "Reviews Sorted by Author" or "Reviews Sorted by Genre" where each page has an alphabetical list of the subcategories for that category. Am I making sense? How can I go about doing this?

  2. mfields
    Member
    Posted 1 month ago #

    I use a custom function which looks a bit like this:

    <?php
    function loop(  ) {
    	global $post;
    
    	$post_class = 'post'; /* Class for all posts. */
    	$post_class .= ( is_sticky() ) ? ' sticky' : ''; /* Don't forget about stickiness. */
    	$post_class .= ( in_category( 4 ) ) ? ' stinky-cheeses' : '';
    	$post_class .= ( in_category( 17 ) ) ? ' blue-monkeys' : '';
    	$post_class .= ( in_category( 66 ) ) ? ' taco-freakout' : '';
    
    	print "\n\t" . '<div class="'. $post_class .'" id="post-' . get_the_ID() . '">';
    		/* Do your normal loop stuff here */
    	print "\n\t" . '</div><!-- end post -->';
    }
    ?>

    Call this function inside the loop in category.php

Reply

You must log in to post.

About this Topic