← Back to All Snippets

Remove WordPress Version Query Strings from Static Scripts and Styles

⚡ Target: functions.php 🔒 Tested: WP 6.6+ / PHP 8.2+ 💻 Lang: PHP
PHP (functions.php)
function tipwp_remove_script_version( $src ) {
    if ( strpos( $src, 'ver=' ) ) {
        $src = remove_query_arg( 'ver', $src );
    }
    return $src;
}
add_filter( 'style_loader_src', 'tipwp_remove_script_version', 9999 );
add_filter( 'script_loader_src', 'tipwp_remove_script_version', 9999 );

Strips ‘?ver=6.6.1’ query parameters from enqueued CSS and JS files to enable static CDN proxy caching and hide WP version details.

← Back to All Snippets Explore Dev Tools →