How to remove WordPress version number

By default WordPress adds a meta tag which displays the WordPress version number that your WordPress site is running on. The version number is added just for tracking. This information can be useful to hacker to identify which version of WordPress you are running. If you are not running the latest version of WordPress the hackers can try to target the known vulnerabilities in that version to hack your site.

Note: This is just one way to identify the version. Also, even if this information is not available hackers might still try to hack it using other ways. So it is recommended that you always have the most up to date version of WordPress running.

In this post I will show you some wrong and right ways to remove this information.

WordPress adds the following meta tag to the head section of the site:

<meta name="generator" content="WordPress 3.4.1" />

There are various ways that can be used to remove this information. Let’s first take a look at the wrong ways which people might suggest doing.

Method 1 (Wrong Way): Hacking the WordPress core.
Edit the /wp-includes/defaults-filter.php file and replace

add_action('wp_head', 'wp_generator');


remove_action('wp_head', 'wp_generator');

You should not do this, as when you upgrade WordPress you might no longer have this hack present.

Method 2 (Wrong Way): Remove wp_head()
WordPress executes the wp_generator() function whenever the wp_head() hook is called. This hook is normally inside the header.php file of your theme. Removing this hook from your header.php file might break other functions/plugins on your site which rely on this hook.

Method 3:
A good way to remove this information is to add the following line to the functions.php file of your theme.

remove_action('wp_head', 'wp_generator');

This solution works and removes the generator information from the head section of your site. However, this is not a complete solution as the version information is also included in the RSS feeds.

Method 4:
The correct way to remove the version information both from the head section and RSS feeds of your site is to add the following code to your functions.php file of your theme.

function my_remove_version_info() {
     return '';
add_filter('the_generator', 'my_remove_version_info');

By adding the above code, the WordPress version number will be removed from the head section and RSS feeds on your site.

Update: Check out my next post (How to remove WordPress version parameter from JS and CSS files) to find out how we can remove the WordPress version from JS and CSS files source tags.

Related posts:

  1. How to remove WordPress version parameter from JS and CSS files
  2. How to hide PHP version in the HTTP Headers
  3. How to hide Nginx version number in headers and errors pages
  4. How to add custom nodes to WordPress RSS feed

5 thoughts on “How to remove WordPress version number”

      1. I had added it to the general functions.php file not knowing there was one specific to the theme. I first added it to the bottom of the file and it gave another error. Adding it to the top of the file worked well. Thanks you.

Leave a Reply