Skip to content

Instantly share code, notes, and snippets.

@freezvd
Forked from devinsays/combine-menus.php
Created February 16, 2016 12:44
Show Gist options
  • Save freezvd/8598c6e5f9e47e1f312b to your computer and use it in GitHub Desktop.
Save freezvd/8598c6e5f9e47e1f312b 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