• Hey,

    I’m trying to figure out how to do this:

    I got a navigation menu that kind of looks like this:

    – Page 1
    – Page 2
    — Sub-Page 1
    — Sub-Page 2
    —– Sub-Sub-Page 1
    —– Sub-Sub-Page 2
    — Sub-Page 3
    – Page 3
    – Page 4
    — Sub-Page 4
    – Page 5

    Now I don’t want the sub-pages to be displayed all the time but only if their respective parent-page or the sub-page itself is active.

    So, if you’re on page 1, 3 or 5 the menu should simply look like this:

    – Page 1
    – Page 2
    – Page 3
    – Page 4
    – Page 5

    And if page 2 or sub-page 1 or 3 is active it should look like this:

    – Page 1
    – Page 2
    — Sub-Page 1
    — Sub-Page 2
    — Sub-Page 3
    – Page 3
    – Page 4
    – Page 5

    And the sub-sub-pages should only be shown if sub-page 2 or one of the sub-sub-pages itself is active…

    I’m including the menu in my template via this:

    <div id="sidebar"><?php wp_nav_menu( array('menu' => 'Navigation' )); ?></div>

    And so far this is what I included in the stylesheet:

    #sidebar li.menu-item ul.sub-menu, #sidebar li.menu-item ul.sub-menu ul.sub-menu {display: none;}
    #sidebar li.current-menu-item ul.sub-menu, #sidebar li.current-menu-parent ul.sub-menu, #sidebar li.current-menu-parent ul.sub-menu ul.sub-menu {display: inline;}

    Now, this works fine in that it hides the sub- and sub-sub-pages unless I click on their parent pages.

    Unfortunately there are still some problems with the sub-sub-pages:

    First the sub-sub-pages are not just shown if sub-page 2 is active but also if I click on sub-page 1 or 3, which I don’t really want to happen… They should appear just if sub-page 2 is active…

    And secondly, which is actually the more important problem, as soon as I click on one of the sub-sub-page items in the menu, the whole sub- and sub-sub-items vanish from the menu and just the parent-pages are shown. That’s something that really shouldn’t happen, but I’m not sure how to make it that the menu stays “stable”…

    Maybe someone understood my problem and is able to help me? ^^

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Problem with custom navigation menu’ is closed to new replies.