{"id":46647,"date":"2026-10-10T17:17:34","date_gmt":"2026-10-10T17:17:34","guid":{"rendered":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/code.dplugins.com\/?p=46647"},"modified":"2026-10-10T17:17:34","modified_gmt":"2026-10-10T17:17:34","slug":"remove-wordpress-version-head-links","status":"publish","type":"post","link":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/code.dplugins.com\/remove-wordpress-version-head-links\/","title":{"rendered":"Remove WordPress Version and Extra Links From the Head"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Removing the WordPress version and other leftover links from the head is a small cleanup most sites can do safely. By default WordPress prints a <code>&lt;meta name=\"generator\"&gt;<\/code> tag with the exact version, a Really Simple Discovery (RSD) link for old XML-RPC clients and a <code>?p=123<\/code> shortlink, and it repeats the shortlink in an HTTP <code>Link<\/code> header.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">None of these help visitors or search engines today. This snippet removes them from the HTML head, the HTTP headers and your RSS feeds.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">The snippet<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"php\" class=\"language-php\">&lt;?php\n\/\/ &lt;meta name=\"generator\"&gt; in the head, and the generator tag in feeds.\nremove_action( 'wp_head', 'wp_generator' );\nadd_filter( 'the_generator', '__return_empty_string' );\n\n\/\/ Really Simple Discovery link, only used by old XML-RPC clients.\nremove_action( 'wp_head', 'rsd_link' );\n\n\/\/ ?p=123 shortlink in the head and in the HTTP Link header.\nremove_action( 'wp_head', 'wp_shortlink_wp_head', 10 );\nremove_action( 'template_redirect', 'wp_shortlink_header', 11 );<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Add it with Scripts Organizer<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/dplugins.com\/downloads\/scripts-organizer\/\">Scripts Organizer<\/a> ships this snippet in its One-Click Import library. To add it by hand:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>In wp-admin go to <strong>Scripts Organizer \u2192 Code Blocks \u2192 Add New<\/strong> and give the block a title.<\/li>\n\n\n<li><strong>Script location<\/strong>: PHP.<\/li>\n\n\n<li><strong>Trigger location<\/strong>: Everywhere. The head is printed on the front end, and feeds need the same filter.<\/li>\n\n\n<li><strong>Action hook<\/strong>: leave it empty. WordPress registers these callbacks in <code>default-filters.php<\/code> before any plugin loads, so <code>remove_action()<\/code> already has something to remove while Scripts Organizer loads Everywhere code.<\/li>\n\n\n<li>Paste the snippet into the PHP editor, enable the block and publish it.<\/li>\n\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">The same code also works unchanged in a small plugin or an mu-plugin file in <code>wp-content\/mu-plugins\/<\/code>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How it works<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>remove_action()<\/code> only works with the same hook and priority the callback was added with. The three <code>wp_head<\/code> callbacks use priority 10; <code>wp_shortlink_header<\/code> is added to <code>template_redirect<\/code> at 11, so the snippet passes 11.<\/li>\n\n\n<li>Removing <code>wp_generator<\/code> covers the HTML head only. Feeds print their own generator tag through <code>the_generator()<\/code>, so filtering <code>the_generator<\/code> to an empty string removes the version there too.<\/li>\n\n\n<li>Older copies of this snippet also removed <code>wlwmanifest_link<\/code>. WordPress stopped printing the Windows Live Writer manifest in version 6.3, so that line did nothing and is gone.<\/li>\n\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Customise it<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">To go further, these lines remove the REST API discovery links and the oEmbed discovery links. The REST API keeps working; only the <code>&lt;link&gt;<\/code> tags and the <code>Link<\/code> header go. Keep the oEmbed links if other sites embed your posts.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"php\" class=\"language-php\">remove_action( 'wp_head', 'rest_output_link_wp_head', 10 );\nremove_action( 'template_redirect', 'rest_output_link_header', 11 );\nremove_action( 'wp_head', 'wp_oembed_add_discovery_links', 4 );\nremove_action( 'wp_head', 'wp_oembed_add_discovery_links' );<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Emoji scripts and block styles are separate cleanups: see <a href=\"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/code.dplugins.com\/disable-emojis-in-wp\/\">Disable Emojis in WP<\/a> and <a href=\"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/code.dplugins.com\/remove-the-gutenberg-block-library-css-from-wordpress\/\">Remove the Gutenberg Block Library CSS from WordPress<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Gotchas<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Hiding the version is not a security fix. Scanners also read it from <code>?ver=<\/code> on core assets and from files like <code>readme.html<\/code>. Keeping WordPress updated is what protects you.<\/li>\n\n\n<li>Some themes print their own generator or pingback tags in header.php; those need a child theme edit.<\/li>\n\n\n<li>Clear page caches after enabling the snippet, or cached pages keep the old head.<\/li>\n\n<\/ul>\n\n","protected":false},"excerpt":{"rendered":"<p>Clean up the WordPress head: remove the generator tag with the WordPress version, the RSD link and the shortlink from the HTML, HTTP headers and feeds.<\/p>\n","protected":false},"author":1,"featured_media":46648,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"slim_seo":{"title":"Remove WordPress Version and Extra Links From the Head","description":"Clean up the WordPress head: remove the generator tag with the WordPress version, the RSD link and the shortlink from the HTML, HTTP headers and feeds."},"_slim_seo_primary_term_category":0,"_slim_seo_primary_term_post_tag":0,"footnotes":""},"categories":[130,3],"tags":[197,198,53,196],"dpc_library":[204],"class_list":["post-46647","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-security","category-wordpress","tag-cleanup","tag-generator","tag-seo","tag-wp-head"],"_links":{"self":[{"href":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/code.dplugins.com\/wp-json\/wp\/v2\/posts\/46647","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/code.dplugins.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/code.dplugins.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/code.dplugins.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/code.dplugins.com\/wp-json\/wp\/v2\/comments?post=46647"}],"version-history":[{"count":1,"href":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/code.dplugins.com\/wp-json\/wp\/v2\/posts\/46647\/revisions"}],"predecessor-version":[{"id":46657,"href":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/code.dplugins.com\/wp-json\/wp\/v2\/posts\/46647\/revisions\/46657"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/code.dplugins.com\/wp-json\/wp\/v2\/media\/46648"}],"wp:attachment":[{"href":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/code.dplugins.com\/wp-json\/wp\/v2\/media?parent=46647"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/code.dplugins.com\/wp-json\/wp\/v2\/categories?post=46647"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/code.dplugins.com\/wp-json\/wp\/v2\/tags?post=46647"},{"taxonomy":"dpc_library","embeddable":true,"href":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/code.dplugins.com\/wp-json\/wp\/v2\/dpc_library?post=46647"}],"curies":[{"name":"wp","href":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/api.w.org\/{rel}","templated":true}]}}