2

I want to be able to assign multiple menu's to 1 navigation location.

But when I want to assign the second navigation, the previous is unassigned.

How would it be possible without breaking the Wordpress core files?

This is what I am aiming for: How can I display a menu on certain pages only?

2
  • Would the menus then display one after the other? What end result are you aiming for? Commented Apr 21, 2015 at 15:55
  • I am building a plugin like this. Problem is, I can't assign multiple menu's to a single location. My plugin desides what menu to load on which page.
    – user40422
    Commented Apr 22, 2015 at 7:27

1 Answer 1

0

is this look like the menu you aiming ?

Screenshot Main and Extra Menu

Here how to create it

Create custom menu in your functions.php ,

// main menu
function main_nav()
{
wp_nav_menu(
array(
    'theme_location'  => 'header-menu',
    'menu'            => '',
    'container'       => 'div',
    'container_class' => '',
    'container_id'    => '',
    'menu_class'      => 'menu',
    'menu_id'         => '',
    'echo'            => true,
    'fallback_cb'     => 'wp_page_menu',
    'before'          => '',
    'after'           => '',
    'link_before'     => '',
    'link_after'      => '',
    'items_wrap'      => '<ul>%3$s</ul>',
    'depth'           => 0,
    'walker'          => ''
    )
);
}

// Extra menu
function menu_extra_nav()
{
wp_nav_menu(
array(
    'theme_location'  => 'extra-menu',
    'menu'            => '',
    'container'       => 'div',
    'container_class' => '',
    'container_id'    => '',
    'menu_class'      => 'menu',
    'menu_id'         => '',
    'echo'            => true,
    'fallback_cb'     => 'wp_page_menu',
    'before'          => '',
    'after'           => '',
    'link_before'     => '',
    'link_after'      => '',
    'items_wrap'      => '<ul id="%1$s" class="%2$s">%3$s</ul>',
    'depth'           => 0,
    'walker'          => ''
    )
);
}

Create Main Menu and Extra Menu in Apparances > Menus

Then add the menu to your desired location, example I put on main nav header

<nav class="nav" role="navigation">
    <?php main_nav(); ?>
    <?php menu_extra_nav(); ?>
</nav>

Then define main and extra menu in your Apparances > Themes > Customize > Navigation

1
  • 1
    Thanks for your try. But no, this is not what I am looking for, it's just 1 menu to 1 location.
    – user40422
    Commented Apr 22, 2015 at 7:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.