How to remove the WordPress version from some .css/.js files
I know that I can use the following function to remove the version from all .css
and .js
files:
add_filter( 'style_loader_src', 'sdt_remove_ver_css_js', 9999 );
add_filter( 'script_loader_src', 'sdt_remove_ver_css_js', 9999 );
function sdt_remove_ver_css_js( $src ) {
if ( strpos( $src, 'ver=' ) )
$src = remove_query_arg( 'ver', $src );
return $src;
}
But I have some files, for instance style.css
, in the case of which I want to add a version in the following way:
function css_versioning() {
wp_enqueue_style( 'style',
get_stylesheet_directory_uri() . '/style.css' ,
false,
filemtime( get_stylesheet_directory() . '/style.css' ),
'all' );
}
But the previous function removes also this version. So the question is how to make the two work together?
Topic wordpress-version Wordpress
Category Web