Home > Dev > WordPress Interface > Removing WordPress Version from Source Code

Removing WordPress Version from Source Code

This code will remove the WordPress version number from the source code.

// Add this to your theme's functions.php file

remove_action('wp_head', 'wp_generator');
add_filter('the_generator', '__return_null');

function remove_version_from_scripts_styles($src) {
    if (strpos($src, 'ver=')) {
        $src = remove_query_arg('ver', $src);
    }
    return $src;
}
add_filter('style_loader_src', 'remove_version_from_scripts_styles', 9999);
add_filter('script_loader_src', 'remove_version_from_scripts_styles', 9999);
Back