Remove WordPress Version Number

By default, WordPress adds its version number to your site’s source code, RSS feeds, and script URLs. While this isn’t harmful, it can expose your WordPress version to bots and potential attackers. This snippet helps you completely remove the WordPress version number for better security and a cleaner output.

// Remove WordPress version from the generator meta tag in the header
remove_action('wp_head', 'wp_generator');

// Remove WordPress version from RSS feeds
add_filter('the_generator', '__return_empty_string');

// Remove version query strings from scripts and styles
function wpsnippetpress_remove_version_query_strings($src) {
    if (strpos($src, '?ver=') !== false) {   
        $src = remove_query_arg('ver', $src);
    }
    return $src;
}
add_filter('script_loader_src', 'wpsnippetpress_remove_version_query_strings');
add_filter('style_loader_src', 'wpsnippetpress_remove_version_query_strings');
PHP

Usage:

Completely removes the WordPress version number from the site's header, RSS feeds, and script/style query strings.

Benefits:

  • Improved Security – Prevents attackers from easily detecting your WordPress version.

  • Cleaner Source Code – Removes unnecessary meta tags and query strings.

  • Better Performance – In some cases, removing query strings can help caching systems.

Frequently Asked Questions

Yes, removing the version number does not affect your site’s functionality. It only hides the version output.
No, updates and plugins will continue to work as normal. This change is only about hiding version details in your site’s output.
You should add this code to your child theme’s functions.php file or a custom plugin. Avoid adding it directly to a parent theme to ensure it’s not lost during updates.

Related Links

Related Snippets

Display Gravity Forms Entries for the Logged-In User
Display Gravity Forms submissions for logged-in users on the frontend using a simple shortcode. Learn...
Hide WooCommerce Prices for Non-Logged-In Users
Hide WooCommerce product prices for visitors who aren’t logged in. It will encourage users to...
Picture of Kishan D
Kishan D
I’m a web developer who builds with WordPress, WooCommerce, and Shopify, and I enjoy exploring React and creating gaming & tech content.

SHARE POST

Leave a Reply