WordPress Multisite: Have the same header and footer of main-blog on all sub-blogs

I’m trying to do the following:

I have a Main-Blog and dozens of subblogs.
I want all the subblogs to use the same theme (or child-theme, not sure yet) but have the same navigationitems of the mainblog on all subblogs? The same for the footer.

How’d I do that?

This is my Main-Blog and Landing-Page

enter image description here

If I click on Subblogs and chose a Subblog i just want the content area to be affected, the header and the footer should stay the same over the entire network.

enter image description here

Inside the content-area of a subblog I’d than like to use the pages and posts of the subblog.

What is the right way to do this?


Update:

<ul role="navigation">
    <?php

        //wp_list_pages('title_li=&depth=1&exclude=42,311');

        $args = array(
            'authors'      => '',
            'child_of'     => 0,
            'date_format'  => get_option('date_format'),
            'depth'        => 1,
            'echo'         => 0,
            'exclude'      => '42,311',
            'include'      => '',
            'link_after'   => '',
            'link_before'  => '',
            'post_type'    => 'page',
            'post_status'  => 'publish',
            'show_date'    => '',
            'sort_column'  => 'menu_order, post_title',
            'title_li'     => '', 
            'walker'       => ''
        );

        $menu = wp_list_pages( $args );
        update_option('network_menu', $menu);
        echo $menu;
    ?>
</ul>

in my child-theme I do:

<ul role="navigation">
    <?php 
        $menu = get_option('network_menu');
            echo $menu;
    ?>
</ul>

3 Answers
3

You could use the switch_to_blog() function

Switches the active blog until the user calls the
restore_current_blog() function. This function is useful if you need
to pull posts, or other information, from other blogs, you can then
switch back after using restore_current_blog(). Using this function
will not load plugins that only run on the blog you switch to.

So you can edit your theme to always pull some header and footer content from the main blog, but still keep the inner content of the sub blogs.

In you theme’s header.php and footer.php files ( and maybe some other template files** ), put switch_to_blog($id_of_main_blog) before hooks/functions that grab the site navigation and place restore_current_blog() after.

**You will need to tweak the exact placements depending on the theme.

Leave a Comment