Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
remove query strings from static content in WordPress
//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