Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save someguy9/fb0790992ebad7fc14e58d84857aca32 to your computer and use it in GitHub Desktop.
Save someguy9/fb0790992ebad7fc14e58d84857aca32 to your computer and use it in GitHub Desktop.
remove query strings from static content in WordPress
<?php
//Remove Query Strings From Static Resources
function smartwp_remove_query_strings_from_static_resources( $src ) {
if( strpos( $src, '?v=' ) ){
$src = remove_query_arg( 'v', $src );
}
if( strpos( $src, '?ver=' ) ){
$src = remove_query_arg( 'ver', $src );
}
return $src;
}
add_filter( 'script_loader_src', 'smartwp_remove_query_strings_from_static_resources', 999 );
add_filter( 'style_loader_src', 'smartwp_remove_query_strings_from_static_resources', 999 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment