Alter WordPress’ Generator Tag
10
Jun '11 By default, WordPress adds a “generator” meta tag to your site header HTML. The content of the tag contains “WordPress” and the version you are running. For example: WordPress 3.1.3
With a simple edit of your theme functions.php file, you can either remove or alter this tag to add a small, additional layer of security.
To alter the tag, as I have done on this site, you can add the following code to your theme functions.php file:
function my_generator_tag($generator, $type = 'xhtml')
{
switch ($type)
{
case 'html':
$html = '<meta name="generator" content="WordPress">';
break;
case 'xhtml':
$html = '<meta name="generator" content="WordPress" />';
break;
}
return $html;
}
add_filter('the_generator', 'my_generator_tag');
Or, if you would like to remove the tag completely, simply add:
remove_action('wp_head', 'wp_generator');
Filed under: Programming