The WPFolks app is out on iPhone and Android. Free, no ads. Download on the App Store Get it on Google Play
Skip to main content
Login Join
Snippet · PHP

Remove WordPress Version Number

Shared by Amit Dholiya · November 23, 2026 · @the_generator (filter), style_loader_src (filter), script_loader_src (filter)

10 views
1 upvote
Back to Snippets

Removes the WordPress version number from your site’s HTML head and RSS feeds. Exposing the version can help attackers target known vulnerabilities in outdated releases, so hiding it is a simple, low-effort security hardening step.

How to add it

  1. Open your child theme’s functions.php via Appearance > Theme File Editor, or use a snippets plugin like WPCode (Code Snippets > Add Snippet > PHP Snippet).
  2. Paste the code below at the bottom of the file or into the snippet box.
  3. Click Update File, or set the snippet to Active and click Save.
  4. Visit your homepage, right-click and choose View Page Source, then search for generator. The WordPress version tag should no longer appear.

How it works

  1. By default, WordPress outputs a <meta name="generator" content="WordPress x.x"> tag in the page head through the wp_head action, and also adds the version to RSS feeds.
  2. The the_generator filter controls the generator output everywhere it appears.
  3. The function returns an empty string, so nothing is printed.
  4. A second filter strips the ?ver= query string from CSS and JS file URLs, which can also reveal the version.
/**
 * Remove the WordPress version from head, feeds, and asset URLs.
 */
add_filter( 'the_generator', '__return_empty_string' );

/**
 * Remove the WordPress version query string from scripts and styles.
 *
 * @param string $src Asset URL.
 * @return string Modified asset URL.
 */
function my_remove_wp_version_from_assets( $src ) {
    global $wp_version;

    if ( strpos( $src, 'ver=' . $wp_version ) !== false ) {
        $src = remove_query_arg( 'ver', $src );
    }

    return $src;
}
add_filter( 'style_loader_src', 'my_remove_wp_version_from_assets', 9999 );
add_filter( 'script_loader_src', 'my_remove_wp_version_from_assets', 9999 );

Tested on

WordPress 6.8

Reported by the author on November 23, 2026. WPFolks has not verified this.

Not tested against WordPress 7.1.5. It may still work.

Know a different way to do this? Add your approach as a variation so folks can compare them side by side.
Submit a variation

0 comments

Proudly supported by