WordPress Q&As Logo
WordPress Q&As Part of the Q&A Network
Q&A Logo

What’s the safest way to remove the WordPress version number from HTML?

Asked on Oct 05, 2025

Answer

To safely remove the WordPress version number from your site's HTML, you can use a simple function in your theme's `functions.php` file. This method involves removing the version number from the head section of your site's HTML output.
<!-- BEGIN COPY / PASTE -->
    function remove_wp_version() {
      return '';
    }
    add_filter('the_generator', 'remove_wp_version');
    <!-- END COPY / PASTE -->
Additional Comment:
  • This code snippet uses the 'the_generator' filter to remove the WordPress version number from the HTML head.
  • Always back up your `functions.php` file before making changes.
  • Consider using a child theme to ensure your changes are not lost during theme updates.
  • Removing the version number can help reduce the risk of targeted attacks on known vulnerabilities.
✅ Answered with WordPress best practices.

← Back to All Questions
The Q&A Network