Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I want to be able to alter what is visible in the menu according to which level in the site structure I am on, for example

on top level page:-

Home Level 1 page (Current) -Level 2 page

-Level 2 page

-Level 2 page

Level 1 page

Level 1 page

Level 1 page

etc

on level 2 page:

Home Level 1 page (Current page parent)

-Level 2page (Current)

     -- Level 3 page (child of current)

     -- Level 3 page (child of current)

     -- Level 3 page (child of current)

-Level 2page

-Level 2page

-Level 2page

on level 3 page

Level 1 page

-Level 2page (parent)

    --Level 3 page (current)

Is this possible and how do I do it?

Many thanks

share|improve this question

closed as off topic by Chip Bennett, toscho Jul 15 '12 at 23:05

Questions on WordPress Development Stack Exchange are expected to relate to WordPress within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.

1 Answer 1

First you should use the menu builder in the backend to create your menu then use the classes for the different list items to hide or display the UL nested under them. For example

li ul { display: none; }
li.current-menu-item ul { display: block; }
li.current-menu-ancestor li ul { display: none; }
li.current-menu-ancestor li.current-menu-item ul { display: block; }

you can use this logic to hide and show all different levels of menus you have based on what page you are in. You may have to play around with parent classes overriding the display style, but thats the idea. If you view source you will see the classes available to you.

share|improve this answer
    
Thanks for this answer. Haven't had a chance to try it out yet but hopefully will in the next few days –  Tony B Nov 4 '11 at 16:29
    
This is primarily a CSS question, and not a WordPress question, but I do use this technique in my Oenology Theme. Take a look at the subnavmenu CSS, to see proof-of-concept for what you're trying to accomplish. –  Chip Bennett Jan 19 '12 at 16:31

Not the answer you're looking for? Browse other questions tagged or ask your own question.