0

WordPress default theme CSS version problem and not loading.

After change the css code not apply the old css only load.

we manually the style version the new code load.

style.css?ver=5.1 to style.css?ver=5.2

How to change wordpress default theme style.css version in WordPress v 5.1

  • I don’t understand the question. Why do you need to change just the version of the default theme’s CSS? – Jacob Peattie Jul 13 at 4:30
  • we changed in css code not apply.. 'style.css?ver=1' then we change manually 'style.css?ver=2' it loading new code – KGR Jul 13 at 4:31
0

you can pass time() function in version parameter. so you dont have to change version to update a css code.

function add_dynamic_version_css_scripts() {
    wp_enqueue_style( 'dynamic-style', get_template_directory_uri() . '/css/custom-style.css','style-css', time() );
}
add_action( 'wp_enqueue_scripts', 'add_dynamic_version_css_scripts' );

let me know if this works for you.

  • this is Custom-style.css i asking default css file – KGR Jul 13 at 5:23
  • yeah, this is just an example. you can add time() in your default css where you enqueue file. – Chetan Vaghela Jul 13 at 5:24
  • ok we try this time() – KGR Jul 13 at 5:26
  • yes. try this. it will generate unique version of file so you dont have to update version every time when you change code in css file. you can also use in js file if you face issue in js version also. let me know if this solve your problem. – Chetan Vaghela Jul 13 at 5:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.