Sign up ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have a structured Custom Menu:

  • parent 1
    • children1_1
    • children1_2
  • parent 2
    • children2_1
    • children2_2
  • parent 3
  • parent 4
    • children4_1


I want the following: on every page, the parent level items will be shown as main menu.

If a parent level item is active, I want to show the child menu items as a separate list somewhere else in the page.

Is there an "easy" way to achieve this, or do I have to list the menu every time and select the current one with PHP and have headache for this for days? :)

Thanks, cadeyrn

share|improve this question
JQuery and css were made for this. – Bainternet Apr 19 '11 at 19:31
No thank's, I want it to work without js (opera mini for example), and also SEO-proof. – petermolnar Apr 19 '11 at 20:11

3 Answers 3

up vote -2 down vote accepted

This plugin do exactly what you want!

share|improve this answer
Thanks! Although I do not want to put it in a widget, this code really does the dirty work. – petermolnar Aug 22 '11 at 14:03
How does this plugin solve the original question? – Tom J Nowell Sep 30 at 19:53

This should be fairly simple to execute, using two calls to wp_list_pages(), and appropriate variables.

For the primary (i.e. top-level) navigation menu, simply use the depth argument, e.g.:

wp_list_pages( array(
     // display only top-level hierarchy
     'depth' => 1
) );

This will output a menu of all top-hierarchical-level Pages.

For the secondary (i.e. child-page) navigation menu, simply grab the ID of the current Page, and pass it as the child_of argument. This requires setting a variable to the $post->ID from inside the Loop, so that it is available outside of the Loop.

e.g. inside the Loop:

$parent_page = get_the_ID();

And then outside the Loop, for your child-page navigation menu:

wp_list_pages( array(
     // display all hierarchical levels
     'depth' => 0,
     // only children of the current Page
     'child_of' => $parent_page
) );

The only caveat is that this child-page menu must come after the Loop, or else you will need to make an initial pass through the Loop, find the $post->ID, and then rewind_posts() before the Loop.

share|improve this answer

Can't you just add some CSS code to your style.css something like display: inline-block; (instead of display: none;) to ul.sub-menu for the li.current_page_item?

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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