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:

<br />
function my_generator_tag($generator, $type = 'xhtml')<br />
{<br />
	switch ($type)<br />
	{<br />
		case 'html':<br />
			$html = '&lt;meta name=&quot;generator&quot; content=&quot;WordPress&quot;&gt;';<br />
			break;<br />
		case 'xhtml':<br />
			$html = '&lt;meta name=&quot;generator&quot; content=&quot;WordPress&quot; /&gt;';<br />
			break;<br />
	}<br />
	return $html;<br />
}</p>
<p>add_filter('the_generator', 'my_generator_tag');<br />

Or, if you would like to remove the tag completely, simply add:

<br />
remove_action('wp_head', 'wp_generator');<br />

๐Ÿ™‚

Eric Sizemore

Iโ€™m a 30 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

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