Snippet

Remove WordPress Version Number

By default, WordPress tells everyone which version it is running. It adds a generator tag with the version number to the head of every page and to your RSS feeds. Your visitors don’t need it, but bots that look for websites running old versions do. Hiding it won’t protect an outdated website (keeping WordPress updated does that), but there is no reason to advertise the number either. You can remove it using the following code. We have covered other ways in our article on how to remove the WordPress version number.

Where to place? functions.php of your child theme, or a code snippets plugin.

Usage

  • To stop advertising your exact WordPress version to automated scanners.
  • To keep the source code of your pages and your feeds clean.
  • On client websites where you don’t want to reveal platform details.

Code


// Remove the WordPress version number from the page head and RSS feeds
remove_action( 'wp_head', 'wp_generator' );
add_filter( 'the_generator', '__return_empty_string' );

The version can still appear at the end of some file addresses, like ?ver= on scripts and styles. Those numbers help browsers load fresh files after an update, so we suggest leaving them alone and keeping WordPress up to date instead.

Explanation

  1. Just a comment to identify the code.
  2. Removing the wp_generator function from wp_head, so the generator tag is no longer printed in the head of your pages.
  3. Returning an empty string for the the_generator filter, which removes the version from your RSS and Atom feeds as well.