Wordpress骨骼主题CSS和JS版本控制 [英] Wordpress Bones Theme CSS and JS Versioning

查看:281
本文介绍了Wordpress骨骼主题CSS和JS版本控制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个网站已经使用骨头wordpress主题。无论我做什么,我似乎不能得到版本控制使用wordpress enqueue函数的CSS和JS。

I have a website that has been built using the bones wordpress theme. No matter what I do I can't seem to get versioning to work on css and js using the wordpress enqueue functions.

在骨骼中有东西,也许是一个过滤器

Is there something in bones, maybe a filter that I can't find that is stripping the versioning out?

感谢

推荐答案

你可能很幸运,它不是默认情况下,大多数人尝试和删除它,因为它默认为Wordpress版本号?)。

You're probably lucky that it's not there by default, most people try and remove it as it defaults to Wordpress version number (why?).

我发现最好的方法是添加my_wp_default_styles函数到你的functions.php。另外一个简单的技巧是检查主css文件的最后修改日期,并确定版本的时间戳。

I found the best way to add it is to add the my_wp_default_styles function to your functions.php. Also a neat trick is to check the last modified date of the main css file and make that the version timestamp.

function my_wp_default_styles($styles) {
  $styles->default_version = filemtime(get_template_directory() . '/style.css');
}
add_action("wp_default_styles", "my_wp_default_styles");

这篇关于Wordpress骨骼主题CSS和JS版本控制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆