Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.

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();
?>
share|improve this question
add comment

2 Answers

up vote 0 down vote accepted

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

But wait… why call the same function in every theme when we can simply hook into the wp_footer action (which is called in every good 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.

share|improve this answer
add comment

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.

share|improve this answer
    
it doesnt work, widgets are not showing. –  chifliiiii Jan 18 '12 at 17:41
    
Make sure you're properly calling switch_to_blog() with the right blog id in the function, and dump a few queries to double check that you're on the right blog. –  Nick Budden Jan 19 '12 at 5:06
add comment

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.