Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wordpress - Remove Version Number From CSS

I am using a wordpress theme, and the css file uploads with version number: style.css?ver=1.2.8

The problem is that when i change the css file, the browser keep loading the file without my changes. I can see that the changes were saved on the server, but nothing help to load the right file.

I tried:

function remove_cssjs_ver( $src ) {
if( strpos( $src, '?ver=' ) )
    $src = remove_query_arg( 'ver', $src );
return $src;
}
add_filter( 'style_loader_src', 'remove_cssjs_ver', 10, 2 );

But everything disappeared.

I read the other topics on the subject but nothing helped.

Thank you.

like image 874
Keren Danino Avatar asked Sep 10 '25 21:09

Keren Danino


1 Answers

That below given code may help you.

function vc_remove_wp_ver_css_js( $src ) {
if ( strpos( $src, 'ver=' . get_bloginfo( 'version' ) ) )
    $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 );

Taken from https://wordpress.stackexchange.com/questions/132282/removing-wordpress-version-number-from-included-files

That works for me, hope it will work for you as well.

like image 172
laraib Avatar answered Sep 13 '25 11:09

laraib