WordPress.org

Support

Support » How-To and Troubleshooting » Show child of parent category after click in menu

Show child of parent category after click in menu

  • artshowapplepie
    Member

    @artshowapplepie

    Hi

    I’m fairly new to this so i’ll try to be as specific as I can be.

    I have a problem with my categories in my header menu (using the imbalance theme).
    I want to have my child categories visible after clicking one of the parent categories but I don’t know how to fix this.

    I tried to change the depth (see code below) but this shows all child categories without clicking the parent, and screws up my ‘dropdown’ menu.

    Code in my header.php :

    <div id="categories">
                <ul class="mcol2">
              <?php
                        $data = wp_list_categories('show_count=1&exclude=1&echo=0&title_li=&depth=1&hide_empty=0&orderby=ID');
                        $data = preg_replace('/\<\/a\> \((.*)\)/',' <span>$1</span></a>',$data);
                        echo $data;
                      ?>
                </ul>
            </div>

    Here 2 screenshots of what the menu normally looks like after clicking ‘videos’, and what happens when i change depth=1 to depth=2..

    Header normal

    Header after depth changed to 2

    Again i would just like to click on videos, which opens the categories and after clicking on a parent it should open the child categories.

    Hope someone can help as I’ve been trying for the last 3 days haha

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Show child of parent category after click in menu’ is closed to new replies.