WordPress.org

Support

Support » How-To and Troubleshooting » Display sub-categories of category?

Display sub-categories of category?

  • Hi!
    I have my page ‘archive.php’ display all my posts from where catID=11.

    Is there a way I can list either a) the posts from my sub-categories grouped or b) the sub-categories themselves ?

    So if catID=11 was ‘Sport’ and some subs of that were ‘Football'(ID=12) and ‘Golf'(ID=13), it would output….

    Sport
    Football
    Golf

    Any ideas? Thanks for the help.

    *****************************************

    Found a solution and edited it a bit:

    <?php if (is_category(11) or ($parent == '11')) : // Quote
    
    							$categories = get_categories('child_of=11');
    							foreach ($categories as $cat) {
    
    								$option = '<a href="/category/archives/'.$cat->category_nicename.'">';
    								$option .= $cat->cat_name;
    								$option .= ' ('.$cat->category_count.')';
    								$option .= '</a>';
    								echo $option;
    
    						  }
    				  ?><?php endif; ?>

    Cheers anyways folks!

Viewing 7 replies - 1 through 7 (of 7 total)
Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Display sub-categories of category?’ is closed to new replies.
Skip to toolbar