Skip to main content
All CollectionsSupplementary GuidesWordPressGeneral
Deactivating Embeds within Your WordPress Site
Deactivating Embeds within Your WordPress Site
Rapyd Team avatar
Written by Rapyd Team
Updated over a week ago

Disabling Embeds via Code

To deactivate embeds manually by modifying your theme's code, follow these steps:

  • Access your WordPress site's files using a file manager or an FTP client.

  • Locate your theme's functions.php file. This file is usually found in the wp-content/themes/your-theme directory.

  • Open the functions.php file using a text editor.

  • Add the following code snippet at the end of the file:

function disable_embeds_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');

// Disable the filter that pre-fetches oEmbed data for performance reasons.
remove_filter('pre_oembed_result', 'wp_filter_pre_oembed_result', 10);
}

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

add_action('init', 'disable_embeds_init');
  • Save the changes to the functions.php file and upload it back to your server.

Once you have completed these steps, the embed functionality within your WordPress site will be deactivated.


Disabling Embeds with a Plugin

If you prefer a plugin-based approach, use the "Disable Embeds" plugin. Here's how to do it:

  • Log in to your WordPress admin dashboard.

  • Navigate to "Plugins" > "Add New." And search for "Disable Embeds”. Then Install and activate the "Disable Embeds" plugin.

  • Once activated, the plugin will automatically deactivate the embed functionality.

Conclusion

Embeds in WordPress allow you to easily embed videos, images, tweets, and other types of media from external websites into your own WordPress site.

While embeds can be useful for enhancing your content, there may be situations where you want to disable them for various reasons, such as improving site performance or ensuring a consistent user experience.

Did this answer your question?