Mostly theme's use wp_enqueue_style()
function inside their functions.php file to add style sheet in the header. Here is how to find out if your theme does the same.
Open your wp-content/themes/YOUR_THEME_NAME/functions.php
file, and find out the line which is adding the style sheet, Like:
wp_enqueue_style('main_style', get_stylesheet_directory_uri() . '/style.css');
Or Like:
wp_enqueue_style( 'twentysixteen-style', get_stylesheet_uri() );
You can search for the ID (except for -css
part)... if the ID is: main_style-css
search for just main-style
in your functions.php file, and you should probably find the line of code you were looking for.
Now that you found the code and you know that your theme adds this stylesheet by using wp_enqueue_style()
in functions.php file. You need to update this code for version.
$style_ver = filemtime( get_stylesheet_directory() . '/style.css' );
wp_enqueue_style( 'main_style', get_stylesheet_directory_uri() . '/style.css', '', $style_ver );
As you can see, this code gets the last modified time of style.css file using filemtime()
PHP function and it also converts the time to timestamp using time()
PHP function just to make things clean.
If you don't want the version to dynamically change every time you can simply do this:
wp_enqueue_style( 'main_style', get_stylesheet_directory_uri() . '/style.css', '', '1.5' );
Thats pretty much it. Peace!