Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wordpress CSS and JS Version Numbers Not Working

I am trying to figure out why the version number query string is not being included in any of my JS or CSS files that I set. I have looked through all documentation and tried different methods. I have even tried just removing the version and Wordpress won't add it's own version. Was hoping to get any other ideas to try from someone so I can cache break Cloudflare easier.

wp_enqueue_style( 'theme-stylesheet', get_template_directory_uri() . '/assets/css/style.css', false, '1.0' );

wp_register_script( 'theme-scripts', get_template_directory_uri() . '/assets/js/blacklab.min.js', array( 'jquery' ), '1.0.2', true );
wp_localize_script( 'theme-scripts', 'localVar', $stream_info );
wp_enqueue_script( 'theme-scripts' );
like image 753
Cole Avatar asked Apr 22 '16 23:04

Cole


People also ask

How do I add a version number to a CSS file?

To use CSS versioning, you simply need to add a query string parameter on the href attribute in your HTML page. The query string parameter ? v=2 after the style. css file name is the CSS versioning trick.

How do I change the CSS version in WordPress?

All you have to do is update the number within the Version line each time you make a change to your child theme's stylesheet. This will force WordPress to load the latest version of the file. To edit either file, just right-click on it and choose the View/Edit option.


1 Answers

Odds are that you have a plugin or theme function that is removing the query variable. It's impossible to guess where it might be without seeing your code, but if it was built properly, you should be able to search your plugins and theme folders for:

  • remove_query_arg: Which is the function used to remove the ver string.
  • script_loader_src: The hook which is often used to run the above function.
like image 194
I'm Joe Too Avatar answered Sep 19 '22 01:09

I'm Joe Too