Instantly share code, notes, and snippets.

Embed
What would you like to do?
Get shared menu from the main site displayed anywhere in the WordPress Multisite network
//Get $blog_id to remember where we currently are
global $blog_id;
$current_blog_id = $blog_id;
//switch to the main site which has id of 1
switch_to_blog(1);
//Check if menu exists (regardless location)
if (wp_nav_menu(array('menu' => 'social-links'))):
//output the WordPress navigation menu, use slug/name/id
wp_nav_menu( array( 'menu' => 'social-links') );
endif;
//switch back to the current blog
switch_to_blog($current_blog_id);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment