Wordpress Generator meta tag
7th November 2009
The last WordPress versions has introduced the automatic insertion of Generator meta tag in the HTML HEAD.
So what is the problem?
The Generator meta tag reports both the platform name and the software version; an example is “WordPress 2.8.5“. I don’t know why they decided to expose the version number, a so deprecated and potentially harmful information, directly to everybody “eyes” cos this precious information could facilitate a potential hacking tactic based on specific revision problems.
So… is the Generator meta tag bad?
Security maniacal people surely will have to remove it completely cos it evidently exposes the used software.
In a more general way I’d like to encourage in using it providing the “WordPress” part only (the WP software have to be always up to date). The safer Generator meta tag is can be useful/traced/used by some plugins; an example is the WordPress.com Stats plugin.
The are various ways to remove the Generator meta tag.
- Hard-coded
This is done editing the default-filters.php located in the includes directory
Find
add_action('wp_head', 'wp_generator');
Delete the line or replace it with
// add_action('wp_head', 'wp_generator');
The hook’s call that generates the meta tag is completely deleted or just hidden this way.
This hard-coded approach is the one that give better performances (in therm of Server resources usage) but the modification will disappear when upgrading the WP software to a new release; if you’re going this way you have to edit the file after every upgrade. - Modify the Theme
This is done editing the Theme’s functions.php file (not the WP “includes” one)
Adding a
remove_action('wp_head', 'wp_generator');
line before the end of the file.
This is very simple and produce a permanent solution (related to the Theme).
The change will not been affected by WP upgrades.
NOTE: if the used Theme don’t already have a functions.php file (quite rare nowadays) then it can be created and the content should be something like this: - Use a plugin
There are some plugins that can remove the Generator meta tag; a search will push to the right direction.
Adding a safer Generator meta tag.
It is very trivial and It takes not more than a couple of seconds editing the header.php Theme’s file.
Just add the line
<meta name="generator" content="WordPress" />
before or after the already present <meta lines.
Personally talking: It’s good to me letting know users/robots that I’m using WordPress (a great and free platform); a sort of “Thanks a lot to every involved developer!“. So I’d like to encourage everyone to add the safer Generator meta tag to their Themes.








