How to completely remove the WordPress version number from displaying to improve security

WordPress like any software is not without its security flaws, some things that may not seem like an issue can often end up being a large security threat. WordPress by default displays the current version number in a few different places, this however is easily exploited by hackers looking for outdated installations to exploit. The easiest way to avoid this is by always keeping your WordPress installation up to date, but why not add an extra level of security and completely remove the WordPress version number altogether. In this tutorial we will teach you how to completely remove the WordPress version from displaying to improve security using PHP functions.

Completely remove the WordPress version number using PHP functions

In order to completely remove the WordPress version number, we will add the following PHP to the WordPress functions file. Simply open your functions.php file, then copy and paste the code below. Your WordPress version number will now be completely removed from displaying in your head file, RSS feeds, scripts, and styles.

PHP

// remove wp version from head
remove_action('wp_head', 'wp_generator');

// remove wp version from rss feeds
add_filter('the_generator', '__return_empty_string');

// remove wp version from scripts and styles
function dd_remove_version_scripts_styles($src) {
 if (strpos($src, 'ver=')) {
  $src = remove_query_arg('ver', $src);
 }
 return $src;
}
add_filter('style_loader_src', 'dd_remove_version_scripts_styles', 9999);
add_filter('script_loader_src', 'dd_remove_version_scripts_styles', 9999);

Please Note: It is still recommended that you update WordPress to the latest version because that is the only guaranteed way to keep your site protected. Do not rely solely on this method to keep you 100% secure.

Troubleshooting

If you are having problems getting this tutorial to work please reread the tutorial and try again, if you still cannot get it to work please leave us a comment below and we will respond as soon as possible. Please do not email us with problems regarding this tutorial, only comments will be responded to.