How to remove WordPress version from source code

Last updated December 6th, 2023 00:26

You can easily find out what version of WordPress your website is using from the page’s source code. To do this, right-click on the page in your browser and select “View page source.” You can then easily locate the line that shows the public version of WordPress, which is the line that reads <meta name=”generator” content=”WordPress x.x” />. Simply replace the x’s with your current version of WordPress. However, for security reasons, it’s better if your WordPress version is not visible. This is because if you’re not using the latest version of WordPress, you’re advertising to potential attackers that you’re using an outdated version with known vulnerabilities. Let’s take a look at how to remove the WordPress version from the source code.

How to remove the WordPress version from the source code

The only tool you need to accomplish this is a plugin that allows you to insert your own code into your website. Personally, I use the WPCode plugin, which is available in the official WordPress repository. You can easily install it from the “Plugins” link in the left-hand menu of your WordPress dashboard. For a complete guide on how to insert your own code into WordPress, click here: How to insert custom codes into WordPress.

WPCode is a small and lightweight plugin that won’t slow down your system. It’s useful whenever you need to modify your website using inserted codes. One plugin can replace several others. WPCode should be included in the arsenal of anyone who needs to modify WordPress functions using external code snippets.

PHP code to remove the WordPress version from the source code

To use WPCode, create a new basic snippet and select PHP as the snippet language. Then, copy the following code into the field for inserting code:

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

Save and activate the snippet. If you have a caching plugin installed on your website, you will need to clear it to see the inserted code take effect on the website. You can see the difference between using the snippet and not using it here:

How to remove WordPress version from source code
How to remove WordPress version from source code

As you can see, the first image clearly defines the version of your CMS in the page source code. In this case, it’s version 6.2. In the second image, where the above-mentioned snippet was used, the system version is already missing. The line is empty.

Conclusion

WordPress security is crucial and should not be underestimated. On the one hand, hiding the WordPress version may seem like a trivial matter. And maybe it is, in this context. However, it is one of many minor modifications that will contribute to the overall security of your website. And if there are 5 of these minor modifications, they become a rather interesting package of tweaks that contribute to the overall security of your website.

More content about WordPress

Whole category is here

The website is created with care for the included information. I strive to provide high-quality and useful content that helps or inspires others. If you are satisfied with my work and would like to support me, you can do so through simple options.

Byl pro Vás tento článek užitečný?

Klikni na počet hvězd pro hlasování.

Průměrné hodnocení. 0 / 5. Počet hlasování: 0

Zatím nehodnoceno! Buďte první

Jak užitečný vidíte tento článek.

Sledujte mě na sociálních médiích.

Je mi líto, že pro Vás nebyl článek užitečný.

Jak mohu vylepšit článek?

Řekněte mi, jak jej mohu zlepšit.

newsletter

Subscribe to the Newsletter

Stay informed! Join our newsletter subscription and be the first to receive the latest information directly to your email inbox. Follow updates, exclusive events, and inspiring content, all delivered straight to your email.

Odebírat
Upozornit na
guest
0 Komentáře/ů
Nejstarší
Nejnovější Nejvíce hlasováno
Vložené zpětné vazby.
Zobrazit všechny komentáře.

Pokud mi chcete napsat rychlou zprávu, využije, prosím, níže uvedený
kontaktní formulář. Děkuji.

Další Kontaktní údaje