Support » Networking WordPress » Adding a Global Menu for a Multisite installation

  • Resolved novacode7

    (@novacode7)


    I’m creating a multisite installation for a school where each teacher has their own blog. I want to maintain a unified design including the same menu on each blog. I’ve scoured the web and finally found one way to do this that actually works.

    //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);

    Placing this code in the header of the child theme I’m using for the teacher pages causes them to grab the header from the main site. Where it says “add your arguments” I simply placed the existing wp_nav_menu. This seems to be working great, but I’m wondering if there is any other way of doing this?

Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Adding a Global Menu for a Multisite installation’ is closed to new replies.