Wordpress Bones Theme CSS and JS Versioning

后端 未结 2 372
独厮守ぢ
独厮守ぢ 2021-01-21 05:40

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 funct

2条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-21 06:38

    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?).

    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");
    

提交回复
热议问题