Same footer on all multisites blogs

There is any way of using the main site footer (blog id =1) on all the network sites.
I want to have the same footer in all the network.
On the main site i got a theme and the child sites created by users got another theme.

Basically i want to use the same footer on both themes but manage all the widgets from just the main site.

Read More

Its possible to do this using switch_to_blog or something similar?

UPDATE:
I tried but no luck:

<?php
    global $switched;
    switch_to_blog(1);

     get_footer(); 

restore_current_blog();
?>

Related posts

Leave a Reply

2 comments

  1. First of all, using the same footer.php file for multiple themes would be problematic, as different themes use different elements which need to be closed in this file.

    A better way would be to create a custom function that you call in every footer.php file. Such a function would be best placed in a file in wp-content/mu-plugins so it is loaded first for every site:

    function my_custom_footer() {
        echo 'Copyright &copy ' . date('Y') .' ACME Studios Inc.';
    }
    

    And then call the function in a theme’s footer.php file:

    my_custom_footer();
    

    Another method instead of calling the same function in every theme would be to to hook into the wp_footer action (which should be called in every theme):

    function my_custom_footer() {
        echo 'Copyright &copy ' . date('Y') .' ACME Studios Inc.';
    }
    add_action( 'wp_footer', 'my_custom_footer' );
    

    Dropping this latest snippet into a file in wp_content/mu-plugins will make the text appear in the footer of every theme! If you want to manually position or style the text, you can do so by locating the call to wp_footer() in a theme’s footer.php file and wrapping it in HTML elements.

    If you’d prefer to leave wp_footer() for hidden HTML content such as footer scripts, you can call your own action in footer.php and then hook into it whereever you like:

    In footer.php:

    do_action( 'wpse_footer_content' );
    

    In a mu-plugin:

    add_action( 'wpse_footer_content', function () { ?>
    
        content goes here
    
    <?php } );
    
  2. Yes. Just use switch_to_blog and restore_current_blog on either end of the footer, then code your footer as if you were on your main blog between those functions.