Created
September 9, 2019 19:34
-
-
Save someguy9/fb0790992ebad7fc14e58d84857aca32 to your computer and use it in GitHub Desktop.
remove query strings from static content in WordPress
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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