WordPress – Remove query version string from static resources

Last Updated: January 28, 2019

Add to theme functions.php

// remove query string from static files
function remove_script_version_query_string( $src ) {
    if( strpos( $src, '?ver=' ) )
    $src = remove_query_arg( 'ver', $src );
    return $src;
}
add_filter( 'style_loader_src', 'remove_script_version_query_string', 10, 2 );
add_filter( 'script_loader_src', 'remove_script_version_query_string', 10, 2 );

Add your feedback or comment below: