Remove WordPress Version From HTML Source
Custom Code Solution
Add this code to your theme's functions.php
file or a custom plugin:
Remove WordPress version number from various locations:
function remove_wordpress_version_number() {
return '';
}
add_filter('the_generator', 'remove_wordpress_version_number');
Remove version from CSS and JS files:
function remove_version_from_styles_scripts($src) {
if (strpos($src, 'ver=')) {
$src = remove_query_arg('ver', $src);
}
return $src;
}
add_filter('style_loader_src', 'remove_version_from_styles_scripts', 9999);
add_filter('script_loader_src', 'remove_version_from_styles_scripts', 9999);
Remove version from RSS feeds:
function remove_version_from_rss() {
return false;
}
add_filter('do_feed_rss2_comments', 'remove_version_from_rss', 1);
add_filter('do_feed_rss2', 'remove_version_from_rss', 1);
What These Code Snippets Do
- First snippet removes the meta generator tag that shows WordPress version
- Second snippet removes version numbers from CSS and JavaScript files
- Third snippet removes version information from RSS feeds
Plugin Solutions
If you prefer using a plugin, here are reliable options:
-
Hide My WP Ghost - Premium security plugin with version number removal
-
Security Headers - Free plugin that includes version number removal
Additional Security Tips
- Keep WordPress core, themes, and plugins updated
- Use strong passwords and limit login attempts
- Consider using a security plugin for additional protection
- Regularly backup your website
- Use SSL certificate (HTTPS)
The custom code solution is the most lightweight approach and doesn't require additional plugins. Place any of these code snippets in your theme's functions.php
file or in a site-specific plugin for better portability across themes.