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
Comments
  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.

Leave a Reply