• Resolved paa1605

    (@paa1605)


    Hi guys,

    i need some help at finding a solution to a current problem im having. At the moment i know how to list all subcategories for a given category on it’s category page. For example, if a user is on the ‘sports’ category page, i can list all the sport sub categories by adding the following code:

    <?php
    $cat_id = get_query_var(‘cat’);

    $catlist = wp_list_categories(‘echo=0&orderby=id&title_li=&child_of=’ . $cat_id);

    if ($catlist) {
    echo $catlist:
    } else {
    // do your loop stuff
    }
    ?>

    Now the problem im having is that this code won’t work when i place it on a child category. For example, if i have a category of brands > Nike > Football, placing the code on the Nike category page does not return a list showing the football category. Does anyone know why this is? Can anyone help in amending the code so that it does work?

    Thanks.

  • The topic ‘Problem when trying to list child categories!’ is closed to new replies.