Alter WordPress’ 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

About The Author

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

2 Comments

  1. AJ says:

    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