How To Fix: CSS Updating Issue On Browser

Share Now

###WordPress
Add a random version number at the end of the CSS file you are attaching.

If you are using 'wp_enqueue_style' or 'wp_register_style' functions, you can pass a random (version) number rand(111,9999) to 4th parameter.

wp_register_style( 'custom-style', get_template_directory_uri() . '/css/custom-style.css', array(), rand(111,9999), 'all' );

###HTML
If you are attaching CSS as an HTML tag, you should add “?ver=” at the end of the file name. Examples are here:

<link rel="stylesheet" type="text/css" href="http://website.com/css/custom-style.css?ver=<?php echo rand(111,999)?>">
Picture of Nahid Mahamud

Nahid Mahamud

Web Developer | Graphic Designer | WordPress & Woo-commerce Expert