By default, WordPress adds a generator tag to every page of your blog. Removing the WordPress generator tag involves one simple line of code that is added to the functions.php file in your WordPress theme.
The actual function is in /wp-includes/general-template.php. You could, of course, hack the core file to achieve the same result, but custom hacks will be lost with your next upgrade. Whenever you work with custom functions or use code to override WordPress functions it is always safer to use the template's functions.php.
How to Do It
- To remove the generator meta tag from the web page:
remove_action('wp_head', 'wp_generator'); - To remove it from all output:
add_filter('the_generator', create_function('', 'return "";')); - To remove it from specific output:
add_filter('get_the_generator_TYPE', create_function('', 'return "";'));
Where "TYPE" is one of: HTML, XHTML, ATOM, RSS2, RDF, COMMENT, EXPORT. (Note: applies to WordPress 2.5.0+) - To remove it from all output, with the exception of XML (necessary if you are using the Google Sitemap plugin)
function elpie_remove_generator() { return ''; }
if (function_exists('add_filter')) {
$types = array('html', 'xhtml', 'atom', 'rss2', 'comment', 'export');
foreach ($types as $type)
add_filter('get_the_generator_'.$type, 'elpie_remove_generator');
}
Simply copy one of these lines of code and paste it into your theme's function.php file, after the opening PHP tag.
If you enjoyed this post, make sure you subscribe to my RSS feed!














{ 2 comments… read them below or jump to the comment form to add your thoughts }
Great article. I will come back again soon! Please keep posting more Wordpress tips.
Interesting post, I'm still looking on how to rename the default generated Home tag. Thank you for the great post.
Leave a Comment