@dalbaeb的评论最终导致了深入的讨论和可行的解决方案。非常感谢!
我相信我的孩子主题CSS之所以使用\'ver=<parent-theme-version>
是因为我遵循了WP Codex on child themes 1: 1。我的functions.php
包含以下内容:
add_action(\'wp_enqueue_scripts\', \'theme_enqueue_styles\');
function theme_enqueue_styles() {
wp_enqueue_style(\'parent-style\', get_template_directory_uri() . \'/style.css\');
}
我最终使用的代码是在
https://wordpress.stackexchange.com/a/182023/30783 但互联网上的许多网站都粘贴了它(没有给出适当的信用)。
// Making sure your child theme has an independent version and can bust caches: https://wordpress.stackexchange.com/a/182023/30783
// Filter get_stylesheet_uri() to return the parent theme\'s stylesheet
add_filter(\'stylesheet_uri\', \'use_parent_theme_stylesheet\');
// Enqueue this theme\'s scripts and styles (after parent theme)
add_action(\'wp_enqueue_scripts\', \'my_theme_styles\', 20);
function use_parent_theme_stylesheet()
{
// Use the parent theme\'s stylesheet
return get_template_directory_uri() . \'/style.css\';
}
function my_theme_styles()
{
$themeVersion = wp_get_theme()->get(\'Version\');
// Enqueue our style.css with our own version
wp_enqueue_style(\'child-theme-style\', get_stylesheet_directory_uri() . \'/style.css\',
array(), $themeVersion);
}
Update 2017-01-26
当前的WP主题手册现在包含一个正确的修复程序:
https://developer.wordpress.org/themes/advanced-topics/child-themes/#3-enqueue-stylesheet