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 have a structured Custom Menu:

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

etc.

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
add comment

4 Answers

up vote 0 down vote accepted

This plugin do exactly what you want! http://wordpress.org/extend/plugins/rv-submenus/

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
add comment

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
add comment

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
add comment

Is something like this what you're looking for? This code can be placed anywhere in your template or sidebar, even outside the loop.

http://vonlind.com/2011/04/show-wordpress-child-pages-alongside-parent-page/

share|improve this answer
    
Unfortunately, no. This uses Page's structure, and I have to use Custom Menu because categories, pages, etc. are mixed up all together in the menu (for example, parent1 is a page, childer1_1 is a page, but children1_2 is a category, and so on) –  petermolnar Apr 20 '11 at 5:27
add comment

Your Answer

 
discard

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.