Skip to content

Instantly share code, notes, and snippets.

@partiallyblind
Forked from devinsays/combine-menus.php
Created May 8, 2016 10:27
Show Gist options
  • Save partiallyblind/d08f9b742f69fe72f8025ffcbdae5d38 to your computer and use it in GitHub Desktop.
Save partiallyblind/d08f9b742f69fe72f8025ffcbdae5d38 to your computer and use it in GitHub Desktop.
Combines two WordPress menus into one.
<?php
/**
* Combines the markup of two menu areas into one.
*/
// Get the markup list items in the first menu.
$menu = wp_nav_menu( array(
'theme_location'=> 'menu-1',
'fallback_cb' => false,
'container' => '',
'items_wrap' => '%3$s',
'echo' => false
) );
// Display menu-2 with all the list items from menu-1 included.
wp_nav_menu( array(
'theme_location' => 'menu-2',
'items_wrap' => '<ul id="%1$s" class="%2$s">%3$s ' . $menu . '</ul>',
) );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment