Reputation: 366
I tried to remove all version string query except for main stylesheet because I often update the stylesheet, and I want it refreshed everytime it's updated (by manually adding its version)
Here's how I remove the version
function vc_remove_wp_ver_css_js( $src ) {
if ( strpos( $src, 'ver=' ) )
$src = remove_query_arg( 'ver', $src );
return $src;
}
add_filter( 'style_loader_src', 'vc_remove_wp_ver_css_js', 9999 );
add_filter( 'script_loader_src', 'vc_remove_wp_ver_css_js', 9999 );
How can I add exception, so main style.css will still show its version
thanks
Upvotes: 4
Views: 696
Reputation: 4116
Simple check for style.css
not in current source file, It will remove all ver
query string from source file except from style.css
function vc_remove_wp_ver_css_js( $src ) {
if ( strpos( $src, 'ver=' ) && !strpos( $src, 'style.css' ) )
$src = remove_query_arg( 'ver', $src );
return $src;
}
add_filter( 'style_loader_src', 'vc_remove_wp_ver_css_js', 9999 );
add_filter( 'script_loader_src', 'vc_remove_wp_ver_css_js', 9999 );
Upvotes: 5