Title: Remove Query Strings from static resources
Last modified: August 20, 2016

---

# Remove Query Strings from static resources

 *  Resolved [brando71](https://wordpress.org/support/users/brando71/)
 * (@brando71)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/remove-query-strings-from-static-resources/)
 * In order to achieve that result, I added this code to _functions.php
 *     ```
       function _remove_script_version( $src ){
       	$parts = explode( '?', $src );
       	return $parts[0];
       }
       add_filter( 'script_loader_src', '_remove_script_version', 15, 1 );
       add_filter( 'style_loader_src', '_remove_script_version', 15, 1 );
       ```
   
 * this lines works like a charm, but actually I need this couple of css files (
   from GD Star Ratings plugin) to be untouched:
 * /wp-content/plugins/gd-star-rating/css/gdsr.css?ver=1.9.20
    /wp-content/gd-star-
   rating/css/rating.css?ver=1.9.20
 * Any idea about how to set a filter to exclude a particular css/js file from the
   above script code?
 * Thanks in advance for the help.

Viewing 4 replies - 1 through 4 (of 4 total)

 *  [vtxyzzy](https://wordpress.org/support/users/vtxyzzy/)
 * (@vtxyzzy)
 * [13 years, 8 months ago](https://wordpress.org/support/topic/remove-query-strings-from-static-resources/#post-3049342)
 * I think this will do what you want:
 *     ```
       function _remove_script_version( $src ){
       	$excludes = array(
       		'/wp-content/plugins/gd-star-rating/css/gdsr.css?ver=1.9.20',
       		'/wp-content/gd-star-rating/css/rating.css?ver=1.9.20'
       	);
       	$result = $src;
       	if ( ! in_array($src, $excludes) ) {
       		$parts = explode( '?', $src );
       		$result = $parts[0];
       	}
       	return $result;
       }
       ```
   
 *  Thread Starter [brando71](https://wordpress.org/support/users/brando71/)
 * (@brando71)
 * [13 years, 8 months ago](https://wordpress.org/support/topic/remove-query-strings-from-static-resources/#post-3049358)
 * Thanks vtxyzzy! It worked!!!
 *  [gmorchio](https://wordpress.org/support/users/gmorchio/)
 * (@gmorchio)
 * [13 years, 7 months ago](https://wordpress.org/support/topic/remove-query-strings-from-static-resources/#post-3049443)
 * Hi there, great tip, but, what about external css like [http://fonts.googleapis.com/css?family=Play&ver=3.4.2](http://fonts.googleapis.com/css?family=Play&ver=3.4.2),
   that when I enable
    style_loader_src breaks it?
 * Thanks in advance!
    Regards
 *  [grayloon](https://wordpress.org/support/users/grayloon/)
 * (@grayloon)
 * [12 years, 10 months ago](https://wordpress.org/support/topic/remove-query-strings-from-static-resources/#post-3049502)
 * I also found the script useful but need to exclude an external javascript call.
   Anyone?

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Remove Query Strings from static resources’ is closed to new replies.

## Tags

 * [query strings](https://wordpress.org/support/topic-tag/query-strings/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 4 replies
 * 4 participants
 * Last reply from: [grayloon](https://wordpress.org/support/users/grayloon/)
 * Last activity: [12 years, 10 months ago](https://wordpress.org/support/topic/remove-query-strings-from-static-resources/#post-3049502)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
