This function will remove the “?ver” from the URLs of of your static resources on your WordPress site. For example, it will remove the “version” from the link to your .css and .js files. This can increase your page speed in tests by GTMetrix and Pingdom.
However, please note that some WordPress plugins depend on the “version” query strings and thus will break if you remove them. So, test to make sure that all of your plugins work after using this. (All of the 30+ plugins that I use work fine with this.)
// Remove the 'ver' query string from static files function isa_remove_cssjs_ver( $src ) { // Does this URL have a query string beginning with ?ver= $ver = strpos( $src, '?ver=' ); if ( $ver !== false ) { $parts = explode( '?', $src ); $src = $parts[0]; } return $src; } add_filter('style_loader_src', 'isa_remove_cssjs_ver', 10, 2); add_filter('script_loader_src', 'isa_remove_cssjs_ver', 10, 2);
Also see these for how to remove other query strings in WordPress:
Remove URL Query String Parameters from Gravatars in WordPress
Remove Query String From SyntaxHighlighter CSS URLs.
Veet
October 14th, 2018 at 3:12 pm
Hello Isabel and why don’t you use some plugin??
https://wordpress.org/plugins/remove-query-strings-littlebizzy/
I think it faster. thanks