Created
June 28, 2016 20:44
-
-
Save chinmayrajyaguru/f0af7192c23a83ff01acac120ef06fac to your computer and use it in GitHub Desktop.
Remove WordPress Query Strings From Static Resources
This file contains hidden or 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
#add this to functions.php | |
function _remove_query_strings_1( $src ){ | |
$rqs = explode( '?ver', $src ); | |
return $rqs[0]; | |
} | |
if ( is_admin() ) { | |
// Remove query strings from static resources disabled in admin | |
} | |
else { | |
add_filter( 'script_loader_src', '_remove_query_strings_1', 15, 1 ); | |
add_filter( 'style_loader_src', '_remove_query_strings_1', 15, 1 ); | |
} | |
function _remove_query_strings_2( $src ){ | |
$rqs = explode( '&ver', $src ); | |
return $rqs[0]; | |
} | |
if ( is_admin() ) { | |
// Remove query strings from static resources disabled in admin | |
} | |
else { | |
add_filter( 'script_loader_src', '_remove_query_strings_2', 15, 1 ); | |
add_filter( 'style_loader_src', '_remove_query_strings_2', 15, 1 ); | |
} |
I had tested this in LocalHost & Live websites. You may try it. It's working. If you get any error then let me know. I will help you and resolve it @Highacid
It is working perfect, thanks a lot
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Does this works as a standalone plugin?