X

How to Remove WordPress oEmbed Related Items

Snippets by IsItWP

Are you looking for a way to disable some oEmbed-related functionalities? Remove the REST API endpoints, oEmbed auto discovery, and oEmbed-specific JavaScript from the front-end and back-end. While there’s probably a plugin for this, we have created a quick code snippet that you can use to remove WordPress oEmbed related items.

Instructions:

All you have to do is add this code to your theme’s functions.php file or in a site-specific plugin:

//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 JavaScript from the front-end and back-end.
remove_action('wp_head', 'wp_oembed_add_host_js');

oEmbed provides an easy way to embed content from one site to another. You’re probably familiar with it on sites like YouTube and Twitter. But what if you don’t want other sites embedding your stuff? In that case, this snippet is for you.

Note: If this is your first time adding code snippets in WordPress, then please refer to our guide on how to properly add code snippets in WordPress, so you don’t accidentally break your site.

If you liked this code snippet, please consider checking out our other articles on the site like: 43 best photography themes for WordPress and how to create stunning WordPress optin forms.

Comments  Leave a Reply

  1. Thank you, exactly what I needed because Linkedin uses oembed for sharing links, so it always displayed internal WP title instead of og:title. Just wasted an hour figuring out until this saved me!

    1. Glad it helped, Tobiv 🙂

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

WordPress Launch Checklist

The Ultimate WordPress Launch Checklist

We've compiled all the essential checklist items for your next WordPress website launch into one handy ebook.
Yes, Send Me the Free eBook!
[63% OFF Today!]
[63% OFF Today!]
[60% OFF Today!]
[60% OFF Today!]
[50% OFF TODAY!]
[50% OFF TODAY!]
[63% OFF Today!]
[63% OFF Today!]
[60% OFF Today!]
[60% OFF Today!]
[50% OFF Today!]
[50% OFF Today!]