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();
?>
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 inwp-content/mu-plugins
so it is loaded first for every site:And then call the function in a theme’s
footer.php
file: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):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 towp_footer()
in a theme’sfooter.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 infooter.php
and then hook into it whereever you like:In
footer.php
:In a mu-plugin:
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.