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.

,

Leave a Reply

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