Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dannyconnolly/9639376 to your computer and use it in GitHub Desktop.
Save dannyconnolly/9639376 to your computer and use it in GitHub Desktop.
Remove query strings from static resources in wordpress
function _remove_script_version( $src ){
$parts = explode( '?ver', $src );
return $parts[0];
}
add_filter( 'script_loader_src', '_remove_script_version', 15, 1 );
add_filter( 'style_loader_src', '_remove_script_version', 15, 1 );
@jessuppi
Copy link

jessuppi commented Oct 2, 2018

We were using a similar snippet for several years, but it's a bit limited in scope.

If interested, check our free plugin: https://wordpress.org/plugins/remove-query-strings-littlebizzy/

...by default, strings ?=, ?v=, ?ver=, ?version= are removed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment