Security Tips & Tricks Web Development WordPress

WordPress adds a meta tag to the head section of the website by default. This meta tag has the WordPress version number that your website is on. The tag looks like this, where 4.9.1 let’s say is your WP version.

<meta name="generator" content="4.9.1" />

Now, it is not that big an issue if you are using the latest WordPress version as recommended. Nevertheless, you will never want to make your CMS version public.

Next, if your version is public and your WP is not the latest version for some reason, you are going to put your website at a high-security risk. It is important to remove the version number from this meta tag in header and RSS feed as well.

You may find the solution to remove the tag from the head by writing the following piece of code in your functions.php file:

remove_action('wp_head', 'wp_generator');

Yes, this works. It will remove the meta tag named generator from the head. But this is not the complete solution. You will still have your RSS feed showing up your WordPress version. This is thus an incomplete solution to the problem statement we are looking at.

Correct Way!

To remove the WordPress version from the head as well as the RSS feed, add the following piece of code in your functions.php file:

function sh_remove_wp_version() {
    return '';
}
add_filter('the_generator', 'sh_remove_wp_version');

This is the correct way to remove the WP version from the head as well as the RSS feed. However, it is always recommended to use the latest WP version and keep it updated.


Team Smartherd has a decade of experience in online teaching. Our instructors are tech geeks and holds significant experience in their respective domains.