• dswordpress

    (@dswordpress)


    Goal #1 – list all the child cats of current cat – 1 level only – (this works).

    THEN, also include a link to list ALL subcats, nomatter what depth. Like this:

    “Narrow search below:”
    * cat A
    * cat B
    * cat C
    View All Topics:
    * all topics link

    I can’t figure out where to link to – the same category.php doesn’t work because it strips most cats out (see goal #1).

    I need to do the opposite of the above first Goal – I need a list of all grand-children (no direct children).

    This is the code to get the list of sub-cats only (#1). Is there such a thing as a ‘reset button’ so I can call it again, except different? 🙂

    if ( is_category() ) {
      $cat = get_query_var('cat');
      $child_cats = get_categories('child_of='.$cat);
      if ($child_cats) {
        $args = array(
          'title_li' => '',
          'echo' => 1,
    'depth' => 1,
          'child_of' => $cat
        );
    
    ?>
    <h2><?php single_cat_title();?></h2>
    <p><?php echo category_description();?></p>
    <hr>
    ?>
    <ul>
        <?php wp_list_categories($args); ?>
    <!-- can I reset this loop, and enter a link here to grand-child cats, excluding the direct child-cats? -->
    </ul>
    
    <?php } else { ?>
  • The topic ‘a second category template? Or can I ‘reset’ the $args?’ is closed to new replies.