5

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' );
2
  • 1
    What's strange is if I had a version to the end of the file path it works by adding that and the version number I put in. wp_enqueue_style('theme-stylesheet', get_stylesheet_uri() . '?v=1.4', false, '1.4' ); Commented Apr 23, 2016 at 0:55
  • That shows up in the head section as style.css?v=1.4&ver=1.4 Commented Apr 23, 2016 at 0:56

2 Answers 2

10

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.
Sign up to request clarification or add additional context in comments.

1 Comment

In my case, a plugin called "Child Theme Configuratior" was the culprit.
2

There are some plugins which removes the query strings.

In my case, it was W3 Total cache.

enter image description here

This option can be found in W3 Total cache's browser cache section

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.