Remove WordPress Version Number from Head

A short yet handy code snippet to stop the WordPress Version meta information from getting added in the head section.

WordPress automatically adds its current Version number to the head section of the themes. If you view the source of a WordPress-based website, you may find out the WordPress version it is using.

Below given is the meta tag that carries that version information and can be spotted when you right-click and view source of a WordPress site:

<meta name="generator" content="WordPress 4.3.1" />
WordPress Version info inside the meta tag

This extra information about CMS version is added by WordPress itself in order to keep track of the sites that make use of it.

But for security sake, you may not want this particular info to show up in the source of your WordPress site, as it will simply let the people know what version of WordPress your site is making use of. Now, you can imagine about the goods and bads of it.

WordPress Action to remove version meta

We do have an action that may help us to turn-off adding of WordPress generator tag in the head section. Adding the below code in your theme’s functions.php and saving changes will remove that version meta info:

remove_action( 'wp_head', 'wp_generator' );

Hope you find this useful!