How to Disable Embeds in WordPress

In WordPress, embeds refer to the ability to include content from other websites in your WordPress posts and pages.

This feature is powered by a technology called oEmbed, which allows WordPress to automatically retrieve and display content from other sites in a formatted and visually appealing way.

For example, you can use embeds to include a YouTube video or a Twitter post in your WordPress content by simply pasting the URL of the video or tweet into the editor.

Embeds are a convenient way to add multimedia content to your WordPress site without having to worry about coding or formatting. However, they can also add extra resources and code to your site, which can affect its performance.

If you want to disable embeds on your WordPress site, you can use the following code.

Code to Disable Embeds in WordPress

To disable embeds in WordPress, you can add the following code to your theme’s functions.php file:

function disable_embeds_code_init() {

 // Remove the REST API endpoint.
 remove_action( 'rest_api_init', 'wp_oembed_register_route' );

 // Turn off oEmbed auto discovery.
 add_filter( 'embed_oembed_discover', '__return_false' );

 // Don't filter oEmbed results.
 remove_filter( 'oembed_dataparse', 'wp_filter_oembed_result', 10 );

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

 // Remove oEmbed-specific JavaScript from the front-end and back-end.
 remove_action( 'wp_head', 'wp_oembed_add_host_js' );
 add_filter( 'tiny_mce_plugins', 'disable_embeds_tiny_mce_plugin' );

 // Remove all embeds rewrite rules.
 add_filter( 'rewrite_rules_array', 'disable_embeds_rewrites' );

 // Remove filter of the oEmbed result before any HTTP requests are made.
 remove_filter( 'pre_oembed_result', 'wp_filter_pre_oembed_result', 10 );

add_action( 'init', 'disable_embeds_code_init', 9999 );

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

function disable_embeds_rewrites($rules) {
    foreach($rules as $rule => $rewrite) {
        if(false !== strpos($rewrite, 'embed=true')) {
    return $rules;
function my_deregister_scripts(){
wp_deregister_script( 'wp-embed' );
add_action( 'wp_footer', 'my_deregister_scripts' );

More Code Snippets

These are other snippets to boost the performance of your WordPress Site

  1. How to Delay The Execution of JavaScript without a plugin
  2. How to Remove Global Styles in WordPress
  3. How to Disable Heartbeat in WordPress
  4. How to Limit WordPress Post Revisions
  5. How to Disable Comments in WordPress
  6. How to Disable Rest API and Rest API Links
  7. How to Disable Self Pingbacks in WordPress
  8. How to Disable RSS Feeds and RSS Feed Links in WordPress
  9. Disable Emojis in WordPress
Manuel Campos, English Professor

Manuel Campos

I am José Manuel. I am writing about things I know and things that I am learning about WordPress. I hope you find the content of this blog useful.






© 2024 WP SURFER • Made with Love in Costa Rica