Free Wordpress Blog Setup

The Right Way to Remove WordPress Version Number

By Editorial Staff in Tutorials
The Right Way to Remove WordPress Version Number

By default WordPress leaves it’s footprints on your site for the sake of tracking. That is how we know that WordPress is the World’s largest Blogging platform. But sometimes this footprint might be a security leak on your site if you are not running the most updated version of WordPress. Because you are providing the hacker with the useful information by telling them which version you are running.

If you are running the most up to date version of WordPress, which we recommend you do, then you do not have to worry about this tutorial at all. But if for some reason you are not, then it is in your best interest to follow this tutorial.

There are many ways to get rid of the WordPress version number from your header. But there is only one correct way to do this.

Some sites will recommend that you open your header.php file and get rid of this code:

<meta name="generator" content="WordPress <?php bloginfo('version'); ?>" />

Or others will recommend that you open your functions.php and add the following function:

remove_action('wp_head', 'wp_generator');

But both of these ways are offering you an incomplete solution. These ways will simply remove the WordPress version number from your head area. So if someone views your website source, they will not be able to see the version.

But a smart hacker who knows about WordPress will simply go to your RSS Feeds, and they will find your version number there because neither of the above codes will remove that number.

In order for you to completely remove your WordPress version number from both your head file and RSS feeds, you will need to add the following function to your functions.php file:

function wpbeginner_remove_version() {
return '';
}
add_filter('the_generator', 'wpbeginner_remove_version');

By adding this version, you will remove the WordPress version number from all different areas on your site. Above is the right way to remove WordPress Version number.

Note: We still recommend that you update to the latest version of WordPress because that is the only guaranteed way to keep your blog protected.

What Next?

Digg it
Save This Page
Subscribe to WPBeginner
Stumble it
Free Wordpress Blog Setup

Comments

20 Responses to “The Right Way to Remove WordPress Version Number”
  1. Will it remove only the version number or the “WordPress” name too?

  2. I’m sure a lot of bloggers doesn’t know how to remove the wordpress version correctly, this post is a great help.

  3. Duncan says:

    Great tip! nice to see a complete fix tutorial out there.

  4. Djolhan says:

    It’s a nice tips, thanks a lot ! Probably the best way to remove it !

  5. Nick says:

    It’s strange, it gives me the error:
    Call to undefined function: add_filter()

    But I’ve checked the plugin.php file and I have obviously the add_filter() funciont defined.

    Any suggestion? Ths.

  6. Nick says:

    Ok, I’ve found the error.

    You must add the created function in the plugin.php file and not in the function.php file.

  7. Ray says:

    Realized that the “Secure WordPress” plugin already does that for you and more. Assuming most people would be interested in securing their WordPress (not just hiding the version number), it would be better to make use of that plugin to do all these for you.

    Incidentally, I got to know of the Secure WordPress plugin via wpbeginner. http://www.wpbeginner.com/wp-tutorials/11-vital-tips-and-hacks-to-protect-your-wordpress-admin-area/

    Nice work guys! Keep on writing!

    • While plugins are great, they somewhat slow your site down. Why use a plugin if it can be done with a simple function in your functions.php file. But yes Secure WordPress plugin does that as well on all versions older than 2.4.

      • Ray says:

        Would have to agree with you on that: just modding the functions.php would be more efficient than adding a plugin just to remove the version number.

  8. Brian says:

    I was using the remove_action method. Can’t thank you enough :)

  9. The only thing that bothers me about this is that it leaves the line open in the header… not normally an issue but my ocd hates that part :)

  10. topdown says:

    It still leaves the version in the RSS source
    http://wordpress.org/?v=2.9.1

  11. Thats really great tip. Working perfect! Thanks

  12. N1NJA says:

    Thanks dude worked like a charm thanks again keep up the good work :)

  13. Nacin says:

    Removing the generator code has nothing to do with security, frankly. If someone is targeting your site in particular, there are other effective ways to determine a version number. If it’s just a malicious script, it’s going to try every exploit that has ever worked regardless of your version. Indeed, we have never seen an exploit script attempting to do version detection.

    Also, the statement “While plugins are great, they somewhat slow your site down,” is a bit misleading in this context, I feel. Yes, a lot of plugins that do heavy-lifting will increase drag on a server. But a good amount of core uses the Plugin API to hook into itself, using the same methods as a plugin. And adding this code to functions.php is doing the same thing.

Share Your Opinions

Tell us what you're thinking...
and if you want a pic to show with your comment, then get gravatar!

Please make sure that you have read our Comment Policy.

Due to high volume of request from our readers, we are adding this feature that allows you to stay updated with this post's comments without having to participate in the discussion even though we would love your input as always. Don't worry we hate SPAM just as much as you do, so you will never receive any SPAM messages from our site and that's our promise to you.

Subscribe without commenting

Close Bar