Wordpress MultiSite Global Navigation Menu Synchronization
Not to long ago I had a request for a MultiSite WordPress network where all blogs in the network needed to share the same main navigation menus. When I searched around I didn't see anyone talking about this so I figured I would post my solution to the problem.
Within your theme files you can use the WordPress function wp_nav_menu(); which will output the appropriate navigational menu depending on the arguments you supply. You can learn more about this function here. The problem is that in a MultiSite network the navigation is output depending on the current blog being viewed. This makes sense and should be the default behavior. But what if you want to keep a consistent navigation throughout all blogs in the network? You can use the WordPress MU function switch_to_blog() as shown below.
//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);
Before you can output the navigation you first have to create it by visiting Appearance->Menus. But once you get your main menu created placing the above code in your WordPress theme file will allow you to share your main blogs menu amongst all blogs on the network. If you have any questions or comments about this solution feel free to post them in the comments section below.