Controlling the versioning on my style.css within my child theme

Hello,

Currently my style.css within my pro-child theme URL is = “/wp-content/themes/pro-child/style.css?ver=2.4.0”

I would like to remove ver=2.4.0 temporarily or update it upon file change so that the updated version of the file will display on the site.

Is the a Xtheme cache purging or what are my options?

Pro-Child is my active theme

Hello Scott,

Thanks for writing in!

If version 2.4.0 is showing up then it might be the case that you are using Pro Theme 2.4.0. So rather then changing the version number, I would suggest you to update Pro Theme to latest version 2.5.5.

Can you please confirm that the website is running latest version of Pro Theme 2.5.5? If you would like to update Pro Theme, please take a look at following resources:

https://theme.co/changelog/

Thanks.

Thanks. I have updated to 2.5.5 and now my url says: /wp-content/themes/pro-child/style.css?ver=2.5.5 but when I add CSS to style.css within my pro-child - it keeps that ?ver=2.5.5 and does not show me my new additions to style.css within pro-child

Hello Scott,

Thanks for clarifying. This is actually Wordpress’ way of caching the CSS files.

If you make changes to the style.css file of the child theme and you are not seeing any changes, you can fully clear the browser cache so that it will reload the new resources of the site including the CSS files.

If you want to remove the version number of the CSS files, you may use the suggestions here:

Hope this helps.

Hello,

Most times I work with the versioning, it is based on a date of save, but your’s is a static 2.5.5, which means even when I clear my browser cache, it still shows 2.5.5.

I tried those provided within the stackoverflow, and had no luck removing the versioning.

URL: http://site.com/wp-content/themes/pro-child/style.css?ver=2.5.5

Hi Scott,

Try this code:

function remove_theme_version_strings( $src ) {
	
	global $wp_version;
        
    $theme_version = wp_get_theme(get_template())->get( 'Version' );
	parse_str( parse_url($src, PHP_URL_QUERY), $query );

	if ( !empty( $query['ver'] ) && $query['ver'] === $theme_version ) {
		$src = remove_query_arg( 'ver', $src );
	}

	return $src;
	
}

add_filter( 'script_loader_src', 'remove_theme_version_strings' );
add_filter( 'style_loader_src', 'remove_theme_version_strings' );

Kindly note that since this is a custom code that changes the default behavior/display of the theme, you will be responsible to maintain or update the code in case you require further changes or if the code stops working in future updates. If you are uncertain how to proceed, it would be best to get in touch with a developer.

Hope this helps.

That did it! Thanks so much!

Scott

You’re most welcome!

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.