Randomize stylesheet version number SOLVED

Hello,

I was hoping to get some guidance on how to randomize the version number of the child stylesheet. RIght now, it reads /wp-content/themes/pro-child/style.css?ver=2.0.4 and I would like to modify that to something more like /wp-content/themes/pro-child/style.css?ver=2.0.4-29837 for example.

I’ve done this before in different scenarios but need some help making it happen with Pro.

I’m sure there would be a filter or something I could add to the child functions file that would utilize rand(); to make this sort of thing happen for use on a dev site.

Thanks!

Hi There,

Thanks for writing in! Regretfully this isn’t a feature offered by X. It could be possible with custom development, but this would be outside the scope of support we can offer. You may wish to consult a developer to assist you with this. X is quite extensible with child themes, so there are plenty of possibilities.

You can follow some of the solutions provided here.

Thanks for understanding,

Why I want to do this:
Persistent cache due to the development environment

SOLUTION: (for child functions.php)

// Randomize style versions during development
function bust_cache( $src ) {
		$cache_buster = rand(1, 100000);
		$src = remove_query_arg( 'ver', $src );
	return $src . '?ver=' . $cache_buster;
}
add_filter( 'style_loader_src', 'bust_cache', 9999 );

This works well but should be removed when the site is pushed live. Caching the stylesheets is good for end users on a live site but it can be frustrating during development.

Glad you’ve sorted it out.

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