Archive for the ‘Themes’ Category

WordPress MultiSite Global Navigation Menu Synchronization

Tuesday, September 27th, 2011

Is it kosher to copy someone else’s post title? I need to post this here so I remember it. Worst problem: finding a solution and then never being able to find it gain when I need it.

I did this a long time ago and simply put the following in my header.php:

<div id="access" role="navigation">
			  <?php switch_to_blog(1); ?>
<?php wp_nav_menu( array( 'container_class' => 'menu-header', 'theme_location' => 'primary' ) ); ?>
<?php restore_current_blog(); ?>
			</div><!-- #access -->

I just ran across Oste Design which says, I think, approximately the same thing.  This goes in the theme file.

//store the current blog_id being viewed
global $blog_id;
$current_blog_id = $blog_id;

//switch to the main blog which will have an id of 1
switch_to_blog(1);

//output the WordPress navigation menu
wp_nav_menu(
   //add your arguments here
);

//switch back to the current blog being viewed
switch_to_blog($current_blog_id);