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
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 );
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With