
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 // https://wpforthewin.com/remove-related-videos-wp-gutenberg-embed-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

Blogger, expert WordPress developer, and developer of the awesome bbPress Voting plugin which is a must-have plugin for any bbPress forum.
Download bbPress Voting for free on the WordPress Plugin Directory.
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?
Glenn,
I don’t see why this would stop working. I checked the documentation on the “render_block” hook, and it still shows the same type of code as what I’m doing, and I also checked that the YouTube block is still identified as core-embed/youtube
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.
I had to modify to allow for a different 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
Thanks that fixed it for me @Kender :)!
I had to add in
"core/embed" === $block['blockName']
as another option to get it to work with WP 6.xThanks, I updated the post to include that.
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.
Cheers
Brett
I thought it was still working. I did notice someone left a comment suggesting a change, so I just update the post with that. Try that to see if it helps. Otherwise, inspect the embed to see if those parameters are getting included after ?feature=embed
According to https://phpcodechecker.com/, 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?
Glenn, thanks for letting me know. You’re right, I missed a closing parenthesis during my last edit. It’s fixed now.