How to Get Rid of oEmbed rel=”alternate” Tags in WordPress

By Lowell Heddings on June 15th, 2017

WordPress is a great publishing platform with features for anybody and everybody. The problem with WordPress is that it’s full of features for anybody and everybody. So out of the box, it’s a little bloated until you chop it down to size.

For today’s adventure, I wanted to figure out how to delete all of the <link rel=”alternate” type=”application/json+oembed” /> nonsense that gets included — because there’s just no reason for it unless you’re worried about other WordPress sites using oEmbed to link to you. As long as you include Open Graph markup, your users can still share on Facebook, Twitter, etc, and your site will embed there just fine.

Luckily removing these from the template is easy, all you’re going to need to do is open up your theme’s functions.php file and paste in the following line:

remove_action('wp_head','wp_oembed_add_discovery_links', 10 );

Once you’ve done so, both of the <link rel=”alternate” lines will be gone. There will still be a lot of other unnecessary stuff, but I’ll save that for another day.