WordPress: Remove query strings from static resources

This is normal code for remove query strings from static resources. Add the code below to your function.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 );

And add this code if you want to exclude some js or css.

function _remove_script_version( $src ){
	$excludes = array(
	$result = $src;
	if ( ! in_array($src, $excludes) ) {
		$parts = explode( '?', $src );
		$result = $parts[0];
	return $result;


Artikel terkait:   WordPress: Get URL Only of Featured Image

Isi Komentar

Alamat email Anda tidak akan dipublikasikan. Ruas yang wajib ditandai *

This site uses Akismet to reduce spam. Learn how your comment data is processed.