PHP, Wordpress

Removing “Related YouTube Videos” From WordPress oEmbeds

At work the other day, I needed to remove the related section that appears at the end of a YouTube video. (See photo below) YT lets you do this by appending &rel=0 to the video URL, but unfortunately, WordPress strips this with its auto-embedder.

Never Gonna Give You Up Related Videos

I researched WP’s embed hooks and stumbled upon two: embed_oembed_html and oembed_result. These hooks are similar in that they both affect the output of embedded HTML. The difference is that oembed_result only gets called once and embed_oembed_html gets called every time the link is embedded. (WordPress caches the generated HTML.)

I recommend oembed_result but in my case, W3 Total Cache was affecting the output of the embed so I had to use embed_oembed_html.

One thought on “Removing “Related YouTube Videos” From WordPress oEmbeds

  1. Excellent goods from you, man. I’ve understand your stuff previous to and
    you’re just extremely excellent. I really like what you’ve acquirded here, really likee what you are saying and the way iin which you say it.
    You make it enjoyable and you still take care
    of to keep it smart. I can’t wait to readd far more from you.
    This iis really a terrific website.

Leave a Reply

Your email address will not be published. Required fields are marked *