WordPress: Alter Generator Tag

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');

๐Ÿ™‚

Eric Sizemore

Iโ€™m a 36 year old Web Developer, Programmer, and Domainer. I specialize in PHP and MySQL, and have used both extensively since early 2005.

2 thoughts to “WordPress: Alter Generator Tag”

  1. Thanks for the comment on my site. Love the blue color scheme of the theme I made ๐Ÿ™‚

    Dude you’ve got some nice scripts on on your site – cheers.

    If you ever want to write a WordPress-related post/tutorial for my blog at WPExplorer you are always welcome, you can always contact me via twitter ๐Ÿ™‚

    AJ

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.