正如您现在所述,主题A和主题B都已经是子主题,也许您可以尝试将其添加到funcions.php 主题B中的文件-
add_action(\'wp_enqueue_scripts\', \'enqueue_front_scripts\');
function enqueue_front_scripts(){
/** Switch to the parent blog */
switch_to_blog(1); // You may need to change the ID, I don\'t know what ID you main site has
/** Grab the path of the parents \'header.php\' file */
$main_header_style_path = get_stylesheet_directory_uri() . \'/header.css\';
/** Restore the current blog */
restore_current_blog();
/** Enqueue the main header styling */
wp_enqueue_style(\'main-header\', $main_header_style_path);
}
function get_main_header(){
/** Switch to the parent blog */
switch_to_blog(1); // You may need to change the ID, I don\'t know what ID you main site has
/** Grab the path of the parents \'header.php\' file */
$main_header_path = get_stylesheet_directory_uri() . \'/header.php\';
/** Output the main header */
require_once($main_header_path);
/** Restore the current blog */
restore_current_blog(); // Don\'t restore until after you have included the header, otherwise you \'get_blogino()\', etc. calls will reference Theme B
}
然后要包含这两个头文件,您可以这样做(注意,两个主题中的头文件只需调用
header.php) -
get_main_header();
get_header();
我建议你读一下
Function Reference for switch_to_blog()
了解更多信息。
更新
我忘了提到你还需要将你的标题样式与它自己的分开
header.css
在主题A中归档,然后在主题A和主题B中将其排队。
我已经更新了我的代码示例来反映这一点。