为了澄清这一点,对于任何使用Divi主题(但通常是任何WP主题)的人来说,在样式表链接的“头部”使用Dev工具进行简单的检查通常会提供关于句柄的线索,正如Den Isahac之前提到的(由于他提到找不到,所以不清楚)。
Anything before the "-css" on the ID of the link for the stylesheet of the Parent theme is generally that handle.
下面的示例使用Divi,id=“Divi style css”因此$handle=\'Divi style\'

因此,对于Divi,您可以像这样将主题排队:
<?php
function my_theme_enqueue_styles() {
$parent_style = \'parent-style\'; // This is \'twentyfifteen-style\' for the Twenty Fifteen theme.
wp_enqueue_style( $parent_style, get_template_directory_uri() . \'/style.css\' );
wp_enqueue_style( \'child-style\',
get_stylesheet_directory_uri() . \'/style.css\',
array( $parent_style ),
wp_get_theme()->get(\'Version\')
);
}
add_action( \'wp_enqueue_scripts\', \'my_theme_enqueue_styles\' );
?>
没什么好处:浏览器有一种恼人的倾向,即根据其“版本”缓存子样式表。缺点是,即使在刷新/清除缓存后,也无法看到编辑,除非每次编辑后更改css文件中的“版本”号。
可以通过交换来更改此行为wp_get_theme()->get(\'Version\') ($ver参数)用于handyfilemtime( get_stylesheet_directory() . \'/style.css\' ) 相反,它在样式表之后添加一个版本号,该版本号与上次保存子样式表时的时间戳相对应,而不是在该样式表中声明的真正“版本”。您最终可以在上线之前恢复到常规功能,但这在生产过程中非常有用。
因此,Divi的整个排队脚本将变成:
<?php
function my_theme_enqueue_styles() {
$parent_style = \'divi-style\'; // This is \'Divi\' style referrence for the Divi theme.
wp_enqueue_style( $parent_style, get_template_directory_uri() . \'/style.css\' );
wp_enqueue_style( \'child-style\',
get_stylesheet_directory_uri() . \'/style.css\',
array( $parent_style ),
filemtime( get_stylesheet_directory() . \'/style.css\' )
);
}
add_action( \'wp_enqueue_scripts\', \'my_theme_enqueue_styles\' );
?>