October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk2 min

How to Hide WordPress oEmbed Discovery Links in the Page Head

Use a matching remove_action() call to hide WordPress’s oEmbed discovery links in the page head. This does not disable the separate oEmbed REST route.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The two rel="alternate" tags with application/json+oembed and text/xml+oembed are WordPress oEmbed discovery links. To remove those tags, unhook WordPress’s wp_oembed_add_discovery_links callback from wp_head before it runs, using the priority at which it was registered. This hides the discovery markup; it does not, by itself, disable every part of oEmbed or prove that sensitive data was exposed.

What the two links do

WordPress core adds oEmbed discovery links to the page head through wp_oembed_add_discovery_links(). They tell an embedding consumer where it may request an oEmbed representation of a page. The callback was introduced in WordPress 4.4.0. WordPress’s developer reference describes it as adding “oEmbed discovery links in the head element of the website.” WordPress Developer Resources: wp_oembed_add_discovery_links().

As an Amazon Associate I earn from qualifying purchases.

The callback’s output depends on the page and environment: WordPress emits the JSON link on singular content it considers embeddable, and emits the XML link when SimpleXMLElement is available. Do not assume every page or WordPress installation will show both tags.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The presence of these discovery links is not, on its own, evidence that secured information has been exposed. WordPress documents oEmbed as a way for a consumer site to request embed HTML from a provider and describes security filtering applied to discovered embed content. WordPress Developer Resources: oEmbed.

Remove the discovery callback

Add the unhooking code to a child theme’s functions.php or a site-specific functionality plugin, rather than editing a parent theme file. A SitePoint forum reply recommended those locations so a parent-theme update does not overwrite the change; that advice is not confirmation that the snippet has been tested on the original asker’s installation.

add_action( 'after_setup_theme', function () {
    remove_action( 'wp_head', 'wp_oembed_add_discovery_links', 10 );
} );

The example uses priority 10, WordPress’s default action priority. If another component registered the callback at a different priority, use that actual priority instead. The callback and priority must match the registration; WordPress notes that removal cannot succeed before registration or after the callback has already run, and a failed removal does not produce a warning. WordPress Developer Resources: remove_action().

Check the result and troubleshoot

  1. Load a page that previously showed the tags. Inspect its rendered HTML source and search for application/json+oembed and text/xml+oembed.
  2. If either tag remains, check timing and priority. Ensure your code runs after the callback has been registered but before wp_head outputs it. Confirm that the registration priority is the same value passed to remove_action().
  3. Check the code location and caches. Confirm the child theme or functionality plugin is active, then clear relevant page or CDN caches before inspecting the output again.

The exact WordPress version, theme, plugins, and live page output in the SitePoint question are not specified, so its reported rest_no_route 404 cannot be diagnosed from that discussion alone.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

What this change does not disable

WordPress registers its oEmbed REST route separately through wp_oembed_register_route(). Removing the discovery-link callback only targets the head markup. It is not a complete oEmbed shutdown, does not establish that the REST route is unavailable, and does not remove all publicly available metadata. WordPress Developer Resources: wp_oembed_register_route().

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.