Remove WordPress generator meta tag (functions.php hack)

WordPress, a popular blogging software (that we also use) automatically includes a meta tag. What raises concern is that it indicates the version number of WordPress installed.

Unless you keep up with WordPress upgrades as soon as they are released, the generator meta tag might be an invitation for hackers. There are known security vulnerabilities in older versions of WordPress – its creators recommend simply upgrading in such cases.

If, for some reason, you have to be away from your blog for months on end, it might be a good idea to remove this generator tag. A simple functions.php hack takes care of this. Place the code below, in functions.php file of your WordPress theme:

/* Remove WordPress generator meta tag */
function rmv_generator_filter() {
    return ''; }

add_filter('the_generator', 'rmv_generator_filter');

The code above has two parts – a function that returns nothing (thereby deleting the usual return), and the add_filter function is part of the WordPress API and allows you to add custom functions to create/modify/delete data.

Recommended for designers
  1. V.C said at 4:55 pm on July 8, 2009

    I found your post when I was looking for way to delete that generator in my blog.
    Removing this meta tag could make my blog looks like a website :)
    I also want to remove some script of wordpress itself but I don’t know how to remove it.

  2. T-Law said at 2:29 pm on July 14, 2009

    That’s useful, simple and it works, thanks.

  3. david said at 9:35 am on March 29, 2010

    didn’t work for me

  4. G.F. said at 2:47 pm on April 30, 2010

    Great advise! Do you know if it’s possible to place this elsewhere than in wp-includes/functions.php? Reason why I ask is that this is over-written on each upgrade, and it’d be nice if WordPress supported a place where it could survive upgrades without special tender, love and care!

  5. Luca said at 10:36 pm on October 16, 2010

    Many thanks, simple and effective ;)

  6. Leo Plaw said at 3:28 pm on May 21, 2011

    @G.F. the code goes into wp-content/thems/…your.theme…/functions.php NOT wp-includes/functions.php.

    The functions.php file in your theme directories are not overwritten with each upgrade. This is the correct place to add them.

Leave a Reply