【发布时间】:2017-05-16 01:17:35
【问题描述】:
我在浏览器缓存子主题样式表时遇到问题,我需要出队/重新注册,然后使用版本号的时间戳重新入队。出队然后重新入队工作正常,但无论我尝试什么,都没有附加版本号。我尝试将wp_enqueue_style() 的版本参数设置为true 和一个字符串。不管是什么,都没有将版本号作为查询字符串添加到样式表链接 href。我的完整代码sn-p如下。
function custom_dequeue_enqueue_child_styles() {
wp_dequeue_style('mk-style');
wp_deregister_style('mk-style');
$cacheBuster = filemtime(get_stylesheet_directory() . '/style.css');
wp_enqueue_style('jupiter-child-stylesheet', get_stylesheet_directory_uri() . '/style.css', array(), $cacheBuster, 'all');
}
add_action( 'wp_enqueue_scripts', 'custom_dequeue_enqueue_child_styles', 999999999);
【问题讨论】:
-
刚刚测试过,效果很好。
-
听起来你有一个过滤器从你的资产中剥离版本号
-
谢谢各位。我一直在搜寻父主题,试图在其中找到一些东西,但我不知所措。我还测试了当前主机/主题之外的代码 sn-p,它确实有效。
标签: css wordpress function stylesheet