• Hello.

    I use this code to divide my main menu (parent categories) and my sub menu (children of parent categories)

    <?php
    $cat = $cat;
    wp_list_categories("orderby=name&show_count=1&use_desc_for_title=0&hide_empty=0&child_of=$cat&title_li");?>

    It works well, but when I click a child, my sub menu disappear. Obviously because WP is looking for children of the child.

    Is it possible to make it only look for children if the current category is a parent. Shortly, I would like my sub menu to be accessible all the time, and just to change list elements according to which parent is clicked.

    The normal wp_list_categories cannot be used cause the childrens ul is pushing the other parent items below.

    I want a traditional main menu, with sub menu below.

    Possible?

    Thanks!

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

    (@arnii)

    Okay, by using this piece of code;

    <?php
    $cur_cat_id = get_cat_id( single_cat_title("",false) );
    print($cur_cat_id)
    ?>

    I can get the category id!

    But this doesn’t work;

    <?php wp_list_categories('orderby=id&show_count=0&use_desc_for_title=0&child_of=$cur_cat_id&title_li=' . __('') . ''); ?>

    I assume it’s a problem with the wp-list-categories and the variable. But what it is, I can’t figure out…

    Any ideas – anyone?

    Have a look at this thread, it might help you part of the way.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Show only children of parent if there is any children’ is closed to new replies.