• I want to have a category widget which shows all categories in the same family as the current category, or lists the top categories only if no category is selected.

    eg; If I have these categories:

    Cat1
    – cat1.1
    – cat1.1.1
    – cat1.2
    -cat1.2.1
    – cat1.3
    Cat2
    – cat2.1
    – cat2.2
    Cat3
    – cat3.3

    And if I am in category “cat1.2” I want it to list all categories from Cat1 down and nothing else, or only the top of Cat2 and Cat3.

    I have searched but can’t find anything to do this
    Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter barnz2k

    (@barnz2k)

    little more help please?

    What I’ve come up with so far is

    if ( is_category() ) {
      $current_cat = $cat->category_parent;
    
      wp_list_categories('&title_li=&show_count=1&child_of='.$current_cat);
    }

    This seems to show all categories, while below only shows the sub categories

    if ( is_category() ) {
      $current_cat = get_query_var('cat');
      wp_list_categories('&title_li=&show_count=1&child_of='.$current_cat);
    }

    I need it to go just one or two parents higher, and list all below.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘List all categories in current category family?’ is closed to new replies.