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 chinmayrajyaguru/f0af7192c23a83ff01acac120ef06fac to your computer and use it in GitHub Desktop.
Save chinmayrajyaguru/f0af7192c23a83ff01acac120ef06fac to your computer and use it in GitHub Desktop.
Remove WordPress Query Strings From Static Resources
#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 );
}
@uhlhosting
Copy link

Does this works as a standalone plugin?

@chinmayrajyaguru
Copy link
Author

chinmayrajyaguru commented Apr 7, 2017

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

@Menum
Copy link

Menum commented Jan 31, 2018

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