Performance & Security

Disable WordPress oEmbed Without a Plugin

WordPress makes embedding content feel effortless. Paste a YouTube link into the editor and a video player appears. Paste a post link from another WordPress site and a neat preview card shows up with a title, an excerpt, and a featured image. Behind that convenience sits a feature called oEmbed, and it runs on every WordPress site by default, whether you use it or not.

If you never embed outside content and never want other sites embedding yours, oEmbed is dead weight. It adds a JavaScript file to every page, prints extra links in your page head, and exposes a REST API route anyone can query. This guide shows how to disable WordPress oEmbed without a plugin with one code snippet, plus the lighter option, testing steps, and what still works afterward.

What Is oEmbed in WordPress?

oEmbed is an open format that lets one website display content from another website through a simple URL exchange. The oEmbed specification describes how a site asks a provider for embed code and receives ready made HTML in return. WordPress supports oEmbed in both directions at once, which is the part many site owners never realise.

As a consumer, WordPress turns plain URLs into rich embeds. When you paste a YouTube, X, Vimeo, or Spotify URL into a post, WordPress contacts that provider, fetches the embed code, and displays the player or card in place of the link. As a provider, WordPress lets other sites do the same with your content. Anyone can paste one of your post URLs into their own WordPress site and your post appears there as an embed card, complete with your title, your excerpt, and a link back to you.

To make the provider side work, WordPress prints discovery links in the head of every post and page, registers a REST API route at /wp-json/oembed/1.0/embed, adds rewrite rules for URLs ending in /embed/, and loads wp-embed.min.js on the front end. That script handles sizing and messaging for embedded content, and it loads even on pages with no embeds at all.

Why Would You Disable oEmbed?

Most small sites get nothing from oEmbed. If your posts contain no auto embedded videos or social posts, and you do not care whether other sites can embed your articles, the feature only costs you a little performance and a little privacy. Switching it off is a small, sensible cleanup, much like the steps in our guide to remove query strings from WordPress without a plugin.

  • One less script on every page: wp-embed.min.js is small, but it is one more request and one more file for the browser to parse. Removing it is a minor speed win that adds up with other small wins.
  • Cleaner page head: the oEmbed discovery links disappear from your source code, which keeps your markup tidy and removes clues about your setup.
  • Privacy control: other sites can no longer pull your post previews through the embed endpoint, and your site stops advertising that endpoint to the world.
  • Control over your content: nobody can display your posts inside their pages as embed cards. People can still link to you normally, which is how the web is supposed to work.
  • Smaller attack surface: the oEmbed REST route is one more public endpoint. Removing it pairs well with our guide to disable the WordPress REST API without a plugin for sites that need neither feature.

Be honest about the gain. Disabling oEmbed will not rescue a slow site, where heavy images, weak hosting, or too many plugins are usually the cause. Our guide on why your WordPress site is slow covers those bigger problems, and our web hosting guide helps you pick hosting that does not fight you. Treat this cleanup as a finishing touch.

What Should You Do Before Adding the Code?

The full disable method adds PHP code to your site. A syntax mistake in a theme file can produce a white screen, so prepare properly before you start. The preparation takes five minutes and makes the whole job safe and reversible.

  • Back up your site files and database, and confirm you know how to restore the backup.
  • Use a child theme functions file or a code snippets plugin, never the parent theme directly, so a theme update cannot erase your change.
  • Keep FTP or hosting File Manager access ready, so you can remove the snippet in seconds if anything goes wrong.
  • Check whether your existing posts rely on auto embeds. Search your content for pasted video or social URLs, because those embeds will stop rendering after a full disable.

How Do You Fully Disable oEmbed Without a Plugin?

oEmbed has several layers, so a full disable touches each one. The snippet below removes the REST route, turns off discovery, removes the data parsing filter, removes the discovery links and the host script from the head, removes the editor plugin that handles embeds in the classic editor, strips the embed rewrite rules, and removes the pre oEmbed result filter. Paste the whole block into your child theme functions.php file or into a code snippets tool set to run everywhere.

function vtg_disable_oembed() {
    remove_action( 'rest_api_init', 'wp_oembed_register_route' );
    add_filter( 'embed_oembed_discover', '__return_false' );
    remove_filter( 'oembed_dataparse', 'wp_filter_oembed_result', 10 );
    remove_action( 'wp_head', 'wp_oembed_add_discovery_links' );
    remove_action( 'wp_head', 'wp_oembed_add_host_js' );
    add_filter( 'tiny_mce_plugins', 'vtg_disable_embed_tinymce' );
    add_filter( 'rewrite_rules_array', 'vtg_disable_embed_rewrites' );
    remove_filter( 'pre_oembed_result', 'wp_filter_pre_oembed_result', 10 );
}
add_action( 'init', 'vtg_disable_oembed', 9999 );

function vtg_disable_embed_tinymce( $plugins ) {
    return array_diff( $plugins, array( 'wpembed' ) );
}

function vtg_disable_embed_rewrites( $rules ) {
    foreach ( $rules as $rule => $rewrite ) {
        if ( false !== strpos( $rewrite, 'embed=true' ) ) {
            unset( $rules[ $rule ] );
        }
    }
    return $rules;
}

Each line has a specific job. Removing wp_oembed_register_route deletes the public oEmbed endpoint, so requests to /wp-json/oembed/1.0/embed return an error. The embed_oembed_discover filter stops WordPress discovering embed data for pasted URLs. Removing oembed_dataparse stops provider responses becoming embed HTML. The wp_head removals delete the discovery links and the wp-embed script. The tiny_mce_plugins filter removes the wpembed editor plugin, the rewrite filter deletes the /embed/ rules, and removing pre_oembed_result closes the last shortcut for answering embed requests.

After saving the code, flush your rewrite rules once. Go to Settings, then Permalinks, and click Save Changes without altering anything. That single save rebuilds the rewrite rules so the embed rules disappear from the stored set. Then clear every cache you run, including your caching plugin, your CDN, and your browser cache, before you test anything. The official WordPress developer documentation describes each of these hooks if you want to read the source level detail.

What Is the Lighter Option If You Only Want the Script Gone?

Some site owners want the opposite balance. They still embed YouTube videos by pasting URLs, but they dislike wp-embed.min.js loading on pages with no embeds. For that case, dequeue only the script and leave the rest of oEmbed alive.

function vtg_dequeue_embed_script() {
    wp_dequeue_script( 'wp-embed' );
}
add_action( 'wp_footer', 'vtg_dequeue_embed_script' );

Be clear about the limits. Removing the script alone does not fully disable oEmbed. Discovery links stay in the head, the REST route stays open, other sites can still embed your posts, and pasted URLs still become embeds. The script mainly supports resizing and communication for embedded WordPress content, so most video embeds keep working without it. Pick the light option to lose only the script, or the full snippet to remove oEmbed entirely. Using both is pointless.

How Do You Test That oEmbed Is Really Disabled?

Testing takes a few minutes and confirms every layer, not just the visible one. Work through these checks in order after clearing your caches.

  • Check the page source: open your homepage, view the source, and search for wp-embed. A full disable returns no matches. Also search for oembed and confirm the discovery link tags are gone.
  • Try pasting a YouTube URL: create a draft post, paste a YouTube link on its own line, and watch the editor. With oEmbed disabled, the link stays a plain link or shows an error instead of becoming a player.
  • Test your own embed URL: visit one of your post URLs with /embed/ added at the end, such as yoursite.com/sample-post/embed/. A disabled setup returns a 404 page instead of an embed card.
  • Test the REST route: open yoursite.com/wp-json/oembed/1.0/embed?url= followed by one of your post URLs. The endpoint should respond with a route not found error.
  • Check existing content: open older posts that contained auto embeds and confirm how they look now. Convert any important ones to manual embeds, as described next.

What Still Works After You Disable oEmbed?

Disabling oEmbed removes the automatic behaviour, not your ability to show outside content. Manual embeds keep working because they never depended on oEmbed discovery. You can paste a YouTube iframe embed code into a Custom HTML block and the video plays normally. The same applies to maps, forms, and social widgets that give you iframe or script embed code. Block editor embed blocks that rely on oEmbed discovery will stop resolving new URLs, so use the Custom HTML block with the provider iframe code instead.

Normal links keep working as before. Search engines index your pages the same way, and social sharing tools read your Open Graph tags rather than oEmbed data, so disabling oEmbed does not harm SEO. For another privacy cleanup, see our guide to disable Gravatar in WordPress without a plugin.

How Do You Re-enable oEmbed Later?

Reversing the change is simple because nothing was deleted from your database. Remove or deactivate the snippet, then visit Settings, then Permalinks, and click Save Changes once so WordPress rebuilds the embed rewrite rules. Clear caches, confirm wp-embed and the discovery links are back in the page source, and paste a YouTube URL into a draft to confirm auto embeds resolve again.

Frequently Asked Questions

Does disabling oEmbed break my existing YouTube embeds?

Embeds created by pasting a bare URL rely on oEmbed, so they can stop rendering or show as plain links after a full disable. Embeds added with iframe code in a Custom HTML block keep working. Before disabling, check your older posts and convert important auto embeds to manual iframe embeds.

Is removing wp-embed.min.js enough to disable oEmbed?

No. Dequeuing the script removes one file from your pages, but the discovery links, the REST route, and the embed rewrite rules all stay active. Other sites can still embed your posts. Use the full snippet in this guide when you want oEmbed switched off completely.

Will disabling oEmbed hurt my SEO?

No. Search engines do not use oEmbed to rank or index your pages. Your titles, meta descriptions, and Open Graph tags keep working as before. The only visible change is that pasted URLs no longer turn into automatic embeds, and other sites can no longer display your posts as embed cards.

Do I need a plugin to disable WordPress embeds?

No. The code snippet in this guide handles every layer of oEmbed, including the REST route, discovery links, editor plugin, and rewrite rules. Add it to a child theme or a code snippets tool, save your permalinks once, and test the result. Remove the snippet any time to switch embeds back on.

Last updated: December 2026.

Hostinger - Get 20% OFF

Habib ur Rehman

Hello! I'm the founder of VU Tech Geek. As a BSCS graduate and experienced WordPress professional, I'm passionate about technology and education. My Virtual University journey has given me valuable insights and knowledge, which I love to share with fellow students.… More »

Related Articles

Leave a Reply

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

Back to top button

Adblock Detected

Please consider supporting us by disabling your ad blocker