Thursday, December 8, 2022

Remove Generator Tag from WordPress Website

Remove Generator Tag from WordPress Website

Since you are reading this post, you probably already know that WordPress adds a meta generator tag to all websites by default. The generator tag tells us the WordPress version being used to generate and manage the website content.

All website owners who use WordPress should definitely know the version that they are using. However, there are many other ways for you to check the currently installed WordPress version on your website. The problem with the meta generator tag is that it makes the WordPress version information publicly available.

WordPress Generator TagWordPress Generator TagWordPress Generator Tag

Someone with malicious intentions can then use this information to exploit the known vulnerabilities in the particular version. Therefore, it makes sense to remove the generator tag from your WordPress websites. In this tutorial, I will show you exactly how you can get rid of the WordPress generator tag with ease.

Removing the WordPress Generator Tag Without a Plugin

Before directly jumping to the removal process, let's first try to understand how the tag gets added to the WordPress source code in the first place.

The generator tag is added to the source with the help of wp_generator() function that is called using the wp_head hook. There are many other functions called behind the hook after the initial call to the wp_generator() function. However, they won't be an issue if we stop the function call chain at the beginning.

WordPress core files rely on the the wp_head hook to call a bunch of other functions. One of those functions is the wp_generator() function. The line responsible for adding the callback to this function is:

Now, we can undo the effect of the add_action() call with the help of a remove_action() call that looks like this:

The above line had to be added to the functions.php file of your theme. The WordPress generator tag will be removed from any website that uses the above line. Here is a screenshot of the page source with this line added to my theme's functions.php file:

No WordPress Generator TagNo WordPress Generator TagNo WordPress Generator Tag

Removing the WordPress Generator Tag With a Plugin

Just like most other things, you can also find a plugin in the WordPress directory that can get rid of the WordPress generator tag. Here are the steps that you need to follow:

Search for the Meta Generator and Version Info Remover plugin in the WordPress directory.

WP Generator Removal PluginWP Generator Removal PluginWP Generator Removal Plugin

Install and activate the plugin.

Navigate to the Settings > Meta Generator and Version Info Remover option from the main navigation in WordPress admin dashboard. You should see some checkbox options like the image below.

WP Generator Tag Removal Plugin OptionsWP Generator Tag Removal Plugin OptionsWP Generator Tag Removal Plugin Options

They will all be checked by default. A check against the first option titled Remove WordPress default meta generator tag will get rid of the generator tag from you. There are many other options available that remove the version information for a variety of plugins.

Once you have checked the relevant options, click on the Save Changes button at the bottom of the plugin page.

Final Thoughts

Once you have followed the steps listed in either of these sections, you will be able to remove the generator tag from your WordPress website.


No comments:

Post a Comment