WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

So I'm basically upgrading an older site and I need to make it multisite as well for some blogs and such.

I'd like to have the main site Menu(created from the admin) available on the other sites in an elegant way. That is, every site has a theme and it would be nice if I could just wp_nav_menu() on every one.

Any ideas?

I took a look at switch_to_blog() but I see it's deprecated.

Cheers!

share|improve this question
1  
I don't think that switch_to_blog() is deprecated. – Michal Mau Aug 19 '11 at 19:10
1  
To avoid further confusion: WPMU_Functions/switch_to_blog() IS deprecated but Functions/switch_to_blog() IS NOT. – Michal Mau Oct 25 '11 at 22:18

I'd say: Write a short plugin that offers a simple function to output a menu. Then activate it network wide.

share|improve this answer

This is what I've used recently. It's very simple but it works well for me.

    function wp_multisite_nav_menu( $args = array(), $origin_id = 1 ) {

        global $blog_id;
        $origin_id = absint( $origin_id );

        if ( !is_multisite() || $origin_id == $blog_id ) {
            wp_nav_menu( $args );
            return;
        }

        switch_to_blog( $origin_id );
        wp_nav_menu( $args );   
        restore_current_blog();

    }

I've thrown this into a mu-plugin file that hosts a lot of small hooks and functions intended to run network wide.

share|improve this answer
    
solid answer - good one! – Q Studio Apr 3 '15 at 8:58
    
I've added this to an MU plugin, and things work on the main site (1) - but on sub sites in the network (2,3,4), they fallback to wp_page_menu due to not being found. Any ideas? The switch_to_blog() is working as I can retrieve data from the main site (get_bloginfo('name'), get_the_title(3) etc.), I just can't retreive menus. This doesn't seem to be working as it once was. – EHerman Feb 3 at 23:52

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.