How to Remove Unrelated Videos From All WP Gutenberg Video Embed Blocks

Remove YouTube Related Videos WP Block

Looking to get rid of the annoying and horribly unprofessional “related videos” end screen on your professional YouTube video embeds on your WordPress website?

I’ve put together the perfect simple solution in the form of a small code snippet that you can drop into your theme’s functions.php file.

But First, The Bad News

So, it turns out that Google deprecated the rel=0 feature to disable related videos.  You used to be able to put that on your video embed URL and it would disable the related videos feature.

Then later on, Google partially brought it back, but with the change that rel=0 would only show other videos from the same YouTube channel on the related videos end screen (as opposed to showing a bunch of random videos).

The good news is rel=0 will definitely improve the experience by showing more of your videos at the end instead of other people’s videos.

Now, let’s take a look at how to implement this.

The Gutenberg Video Embed Block is Lacking

You are probably staring at this oversimplified block with absolutely no settings besides the YouTube URL and the block alignment.

Wouldn’t it be nice if they had some settings you could change like modestbranding, showinfo, and rel?

The Code Snippet to Enable ModestBranding and Rel=0

Maybe some day… but for now, here is a small code snippet that you can put in the functions.php  file of your theme or child theme, or using the Code Snippets plugin…

// Add modestbranding to WP Gutenberg Video Blocks
function wpftw_modest_youtube_player( $block_content, $block ) {
  if( in_array($block['blockName'], ['core-embed/youtube', 'core-embed', 'core/embed'] ) ) {
    $block_content = str_replace( '?feature=oembed', '?feature=oembed&modestbranding=1&showinfo=0&rel=0', $block_content );
  return $block_content;
add_filter( 'render_block', 'wpftw_modest_youtube_player', 10, 3);

With this code in place, all of your YouTube video blocks across your WordPress website should automatically change so there are no more related videos at the end.

This solution works for videos embedded via the new WordPress block editor (code named Gutenberg).  If you are still using the old WordPress Classic Editor, this solution won’t work.  In that case, you just need to add the parameters in the URL for &modestbranding=1&showinfo=0&rel=0

Notify of

Most Voted
Newest Oldest
Inline Feedbacks
View all comments
Glenn Martin
Glenn Martin
2 years ago

This has worked flawlessly for a long time, but with a recent Gutenberg update (not sure exactly when), it’s not working any more. Any ideas or revised code?

Jamie Rhodes-Simpson
Jamie Rhodes-Simpson
2 years ago
Reply to  Glenn Martin

Nathan: Thanks for the info, very helpful!

Glenn: It didn’t appear to work for me either at first, but loading the page in an Incognito/Private window worked fine. So looks like a caching issue.

2 years ago

I had to modify to allow for a different blockName

if( ( "core-embed/youtube" === $block['blockName'] ) || ( "core/embed" === $block['blockName'] ) )

Also, I have a video that starts at 5 seconds, so I changed “?feature=oembed” to “feature=oembed”

uncertain if the core-embed/youtube has been removed or not, so leaving mine as an OR

Last edited 2 years ago by Kender
Kevin Javitz
Kevin Javitz
1 year ago
Reply to  Kender

Thanks that fixed it for me @Kender :)!

Shel K.
Shel K.
8 months ago
Reply to  Kender

I had to add in "core/embed" === $block['blockName'] as another option to get it to work with WP 6.x

11 months ago

Hi Nathan, I was excited to come across this snippet however, just wanted to check…is it still working as it should? While some of my channel videos appear at the end of each video, its only around 2 or 3 at the most and the rest are random.

Glenn Martin
Glenn Martin
7 months ago

According to, your PHP code has syntax error(s).

Strangely, some other PHP checkers say it’s ok, however – running it on my website (with Code Snippets) crashes the site, saying:

Error Details
An error of type E_PARSE was caused in line 5 of the file /home/customer/www/…………………/public_html/wp-content/plugins/code-snippets/php/admin-menus/class-edit-menu.php(253) : eval()’d code. Error message: syntax error, unexpected token “;”

Would you pretty-please review and revise as approriate?