Performance PHP Beginner

Clean Up wp_head. Remove Unnecessary Link Tags

Remove the wlwmanifest link, shortlink, adjacent post links, REST API discovery link, and oEmbed discovery tags that WordPress adds to every page head by default.

Tested on WordPress 7.1 PHP 8.3 No plugin needed Updated
functions.php 24 lines
add_action( 'init', function() {
    // Windows Live Writer manifest, no longer relevant
    remove_action( 'wp_head', 'wlwmanifest_link' );

    // RSD link for XML-RPC clients
    remove_action( 'wp_head', 'rsd_link' );

    // Shortlink tag e.g. <link rel='shortlink' href='/?p=1'>
    remove_action( 'wp_head', 'wp_shortlink_wp_head', 10 );

    // Adjacent post rel links (prev/next), only useful on some blog setups
    remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10 );

    // REST API discovery link
    remove_action( 'wp_head', 'rest_output_link_wp_head', 10 );

    // oEmbed discovery links
    remove_action( 'wp_head', 'wp_oembed_add_discovery_links' );
    remove_action( 'wp_head', 'wp_oembed_add_host_js' );

    // HTTP header equivalents of some of the above
    remove_action( 'template_redirect', 'rest_output_link_header', 11 );
    remove_action( 'template_redirect', 'wp_shortlink_header', 11 );
} );

Where to add this

Recommended A code snippets plugin Survives theme changes and is easy to switch off.
Child theme At the end of your child theme's functions.php file.
Must-use plugin As a .php file in wp-content/mu-plugins, starting with <?php.

Always add PHP to a staging site first, or have FTP or file manager access ready, so you can undo it if something goes wrong.

A freshly installed WordPress site outputs a surprising number of <link> tags and HTTP headers that serve no purpose on the vast majority of modern sites. Each one adds bytes to every page response and advertises information about your site’s infrastructure to anyone who reads the source. This snippet removes them all in one place.

What the code does

All removals run on the init hook, which fires early enough to cleanly remove actions before they execute.

What Each Removal Does

wlwmanifest_link outputs a link to /wlwmanifest.xml, a file for Windows Live Writer, a desktop blogging application from Microsoft that has been discontinued. No modern workflow needs this.

rsd_link outputs a Really Simple Discovery link pointing to your XML-RPC endpoint. If you’ve already disabled XML-RPC, this link is advertising a disabled feature.

wp_shortlink_wp_head outputs a <link rel="shortlink"> tag with your site’s short URL format (e.g. /?p=123). Search engines ignore it and users never see it in source.

adjacent_posts_rel_link_wp_head outputs <link rel="prev"> and <link rel="next"> tags for navigating between posts. Google officially deprecated these hints in 2019 and no longer uses them for pagination signals.

rest_output_link_wp_head outputs a link advertising the REST API root URL. Combined with the HTTP header equivalent removed at the bottom, this stops both the HTML and header-based REST API discovery hints.

wp_oembed_add_discovery_links and wp_oembed_add_host_js output the oEmbed discovery link and the front-end oEmbed script. If your site doesn’t need other sites to embed your content via oEmbed, removing both is safe.

What This Doesn’t Break

Removing these tags has no effect on front-end functionality, SEO, or WordPress features that visitors and editors use. The REST API itself remains fully functional, only the auto-discovery advertisement is removed. The block editor, WooCommerce, and any plugin that uses the REST API programmatically are completely unaffected.

Measuring the Savings

View the source of your page before and after applying this snippet and search for <link rel=. The removed tags are typically 200–400 bytes each. While individually small, across thousands of page views the savings are measurable, and the cleaner source makes your site look more professionally maintained to developers inspecting it.

This website uses cookies to enhance your browsing experience and ensure the site functions properly. By continuing to use this site, you acknowledge and accept our use of cookies.

Accept All Accept Required Only