# Disable oEmbed Discovery and the Embed Script

> Stops your site from acting as an oEmbed provider: removes the discovery links, the embed REST route and the wp-embed script. Embedding YouTube and similar services keeps working.

- Type: PHP
- Runs: Run everywhere
- Category: [Performance](https://wpide.com/library/category/performance/)
- Tags: performance, oembed, embeds
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/disable-oembed-discovery/

## Code

```php
add_action( 'init', function () {
    remove_action( 'wp_head', 'wp_oembed_add_discovery_links' );
    remove_action( 'wp_head', 'wp_oembed_add_host_js' );
    remove_action( 'rest_api_init', 'wp_oembed_register_route' );
}, 9999 );

add_filter( 'embed_oembed_discover', '__return_false' );

add_action( 'wp_footer', function () {
    wp_deregister_script( 'wp-embed' );
} );
```

## Notes

Other WordPress sites will show a plain link instead of a rich card when they embed your posts.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Disable oEmbed Discovery and the Embed Script" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
