How to update global header and footer
-
01-10-2020 - |
Question
I have a problem with the global header and footer in multisite. When I change the root's header and footer, the subsites (all other blogs) don't update.
This is my code:
global $switched;
switch_to_blog(1);
get_header();
restore_current_blog();
switch_to_blog(1);
get_footer();
restore_current_blog();
Solution
Resolved using this code:
global $switched;
switch_to_blog(1);
//get_header();
$root = realpath($_SERVER["DOCUMENT_ROOT"]);
include ($root.'/wp-content/themes/themename/header.php');
restore_current_blog();
global $switched;
switch_to_blog(1);
//get_footer();
$root = realpath($_SERVER["DOCUMENT_ROOT"]);
include ($root.'/wp-content/themes/themename/footer.php');
restore_current_blog();
Licensed under: CC-BY-SA with attribution
Not affiliated with wordpress.stackexchange