我对多站点中的全局页眉和页脚有问题。当我更改根的页眉和页脚时,子网站(所有其他博客)不会更新。
这是我的代码:
global $switched;
switch_to_blog(1);
get_header();
restore_current_blog();
switch_to_blog(1);
get_footer();
restore_current_blog();
最合适的回答,由SO网友:Phạm Khang 整理而成
使用此代码解决:
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();