Code by Day | Explore By Weekend

How To Hide Related YouTube Videos In Divi Tutorial by Pee-Aye Creative

How To Hide Related YouTube Videos In Divi

Here is a quick Divi tutorial showing you how to easily hide and disable YouTube related videos in your Divi video module.

How To Hide Related YouTube Video Suggestions In Divi

Step 1

Add a class to your video modules where you want to hide the related YouTube videos.

Go the Video Module settings>Advanced tab>CSS Classes & IDs toggle>and paste “pa-hide-related-videos” into the CSS Class field.

Step 2

Add the follow code snippet to the Divi>Theme Options>Integrations>Add code to the < head > of your blog

<script>
jQuery(document).ready(function($ ) {
// add '&rel=0' to end of all YouTube video URL's
// to prevent displaying related videos
$('.pa-hide-related-videos iframe').attr( "src", function( i, val ) {
return val + '&rel=0';
});
});
</script>

Make It Global Sitewide

If you want this to take effect in any Video Module on your site then it’s easier to target them all at once. This eliminates the need to add the CSS class from step 1.

<script>
jQuery(document).ready(function($ ) {
// add '&rel=0' to end of all YouTube video URL's
// to prevent displaying related videos
$('.et_pb_video iframe').attr( "src", function( i, val ) {
return val + '&rel=0';
});
});
</script>

You Did It! Good job!

Nice job, you have just edited the YouTube embed link with jQery, which is a type of code that edits things like HTML. But that’s the boring part, the best part is that you now can use the Divi Video Module without worrying about it showing other people’s videos.

35
Last updated Jan 3, 2021 @ 1:14 pm

Please share this post!

Nelson Lee Miller (aka The Divi Teacher)

Nelson is the owner of Pee-Aye Creative Co in the beautiful state of Pennsylvania. He loves helping small businesses, exploring, building websites with Divi, and teaching others.
Divi Adventure Club Product And Course Membership by Pee Aye Creative

Become A Member!

Gain access to everything we offer!

Learn More

Leave A Response!

Subscribe
Notify of
guest
68 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Olga
Olga
1 year ago

This doesn’t seem to work

Asit
Asit
1 year ago

FYI, the global one doesn’t work.

Maciej
1 year ago

Great tutorial! Love it 🙂 Many people may not use Divi Video Module on their websites, but still very useful for those who use it.

Cliff
Cliff
1 year ago

Global one works for me – brilliant thanks for the share!

Elisandro Borges
Elisandro Borges
1 year ago

Great solution, Nelson! It worked for me! Love it. You are always bringing great ideas to us. Thank you so much! 🙂

Elisandro Fernandes Borges
Elisandro Fernandes Borges

Another great tutorial would be “How to stop videos from playing simultaneously”. Have a nice week. 🙂

Frederick D.
1 year ago

Nelson,

Great work on this post. Seriously. The global version worked very well for me and a client website. The plugin I was using showed up on Wordfence as having been withdrawn from WordPress.org due to changes by YouTube. I almost purchased a plug-in, for $5/month on one site, until I dug a little deeper and found your most excellent post.

Your analysis of the misinformation on Facebook is spot on. I’m glad I took some extra time to dig deeper and find your post.

Thank you and please keep the Divi posts coming!

Dan Palmer
1 year ago

You are a legend I love you thanks for making the effort.

Lisa Roberts
Lisa Roberts
1 year ago

I just used the global one, and it definitely took off the random related videos and I am very happy with that! I tried all sorts of techniques I found from various articles and nothing worked. Like you said, showing your own channel’s related videos is better than random videos based on the user’s search history. Thank you so much!!

Meg
Meg
1 year ago

Thank you. Is there something I can add on to this to auto play the video?

Meg
Meg

Thanks but no, that didn’t work. I was thinking it could be added into the jquery script somehow?

Guillermo
Guillermo
1 year ago

Hello. Its working fine with global and individual methods. I have been able to hide related YouTube video suggestions but am not able to hide related video channels. Is this possible? Thanks very much. And very good job!

Guillermo
Guillermo

Hi. Thanks for your answer. Sorry, my English is not very good. But if you can watch any video on this page https://www.claune.com/audiovisuales/ you understand me. I want to hide the last image. Thanks

Barrie Simpson
1 year ago

Hello Nelson,

Can’t get this to work on either version of the jQuery. I have left the first jQuery code in place on the page – https://jackadamsauthor.com/the-lambeth-walk/

If you could take a look at this for me it would be much appreciated.

Many thanks,

Barrie

Kelly
Kelly
1 year ago

This is great — does it only work on video modules? ie, if I inserted a insert media-> YT url in the text module, would it work? Or could I put the &rel=0 at the end of the video URL? I don’t use the video module as much. Thanks for this tip!

darryl
1 year ago

Well done! works like a charm…….
QUESTION, i prefer to use the native video format post if i can because it allows the video to be played in the post preview mode. Meaning that when i use the blog module in a page that features multiple video posts the video can be played right there along with its truncated text instead of having to open the post itself.

any thoughts? the site i’m doing this on is http://www.sandpoint.tv

Sigi
Sigi
1 year ago

Great job. This worked fine on my website. Now the same for the Divi Video Slider please ;-). Kidding. Your help is very appreciated.

Ayush

I tried using the class and corresponding code for Divi Video Slider, at the end it shows me only my channel’s own videos and not any other random videos. Is this the desired behavior that this code is supposed to do? I was wondering if all the videos could be removed.

Either way! This is better than the random videos, thank you!

Anna
Anna
11 months ago

Worked perfectly! Thank you so much, Nelson. 🙂

Aniket Joshi
Aniket Joshi
11 months ago

Does this work for the code module?

Aniket Joshi
Aniket Joshi

pa-hide-related-videos: this class i have used in code module as I embedded video code in code module. i am facing problem in video module. Is code work for video module only?

Taisa
10 months ago

Just tried with the global method for Gutenberg with the wp-block-embed-youtube class and it didn’t work 🙁 I checked that the script loaded on the code. Shouldn’t it work too? It would be awesome!! 🙂 I will try the divi version when I can.

Ross
Ross
10 months ago

Have just tied both methods and get mixed results play the video one and it end and shows the graphic I set. play it again and it puts up adds for other completely irrelevant videos.
Try it here https://www.powertune4x4.com.au/platetronic-steering-braking-suspension-testing/
and let me know how it goes for you currently set using class for video module method but I get the same if set to global method.

Peter Thompson
Peter Thompson
9 months ago

Thanks very much for this, only solution I’ve found that works without far more complex solutions. Very elegant – I’m an extremely novice webpage designer, but have found several solutions on your site that I haven’t elsewhere. Thanks for taking the time to share.

Ingrid
9 months ago

Hi Nelson, unfortunately it refused to work for me – maybe it has to do with what kind of youtube settings you have… but for me it doesn’t work… too bad. But thanks anyway…

Sylvain Breton
8 months ago

Hello Nelson
Yes it worked with Divi 4.4.8. Thanks a lot!
BUT it show related videos from the same Youtube channel. I prefer having no video proposition at all. Is that possible?
Thank you again!

Sylvain Breton

Thank you very much … at least, we have serious video proposition, not crappy stuff. 👍

ben
ben
7 months ago

Neither method seems to work. Is it only for posts and not pages?

Matt
7 months ago

Only works when I’m logged in to the site. Once logged out and viewing the site it just shows the recommended videos still. This may be the problem others are having who have said it doesn’t work – as it does work for me in certain circumstances.

CJ
CJ
7 months ago

I have reviewed the problem why this works for some people and not others.

One reason is the plugin Wordfence Security. When activated, related videos will still play. When deactivated the solution works.

It would be nice to find a workaround to this issue as in my case I need Wordfence Security 🙂

Mike
6 months ago

Hey Nelson, great resource, thank you! Saved me a bunch of time.

As an FYI, I’ve noticed that LazyLoad by WP Rocket will prevent this from working when the “iframe & videos” option is enabled.

Lazy loading could be why this solution doesn’t work for some people.

I tried putting the code at the end of the page, but still no joy.

Last edited 6 months ago by Mike
Arquímedes
Arquímedes
4 months ago

Thank you Nelson.
Look It works for me but when I use the video module, but it doesn’t work when I embed a video with the code module.
Perhaps this is why it works for some people and not for others.

Erick Fabian
Erick Fabian
3 months ago

Hi Nelson, thanks for the “hiding related video” tip. It worked wonders!

Until the client asked for another video to be added. I had no choice but to use a VIDEO SLIDER MODULE. Sadly, vrecommended videos started popping up.

I tried putting the pa-hide-related-videos in the CSS Class of the video slider module. Didn’t work.

Have we discovered the work around for this?

Thank you.

Erick Fabian
Erick Fabian

Thanks still for all your work.

photoMaldives
2 months ago

Thanks again, Nelson, for sharing your tips n tricks.

charlie
1 month ago

Hi I just did the global and nothing changed. I do need to apply this to every video.
please help

Fanny
Fanny
1 month ago

Nelson, this works great on a standard video module. I already applied it successfully on a client’s website. However, with the video popup of divi supreme pro plugin it doesn’t work. Do I have to paste the code somewhere else?

Adam
Adam
1 month ago

Thought I would help clarify this doesn’t work as intended… It is because YouTube changed how the “rel=0” works back around 2019. It used to a way to remove all the recommended videos at the end but now the “rel=0” is used by YouTube to suggest recommended videos from the same account. So instead of it being just random videos at the end, it will now show the other videos from your channel as recommendations to the viewer.

Asset 7

Shop Our Divi Products

Plugins • Courses • Templates

Visit The Shop

Divi Adventure Club Product And Course Membership by Pee Aye Creative

Become A Member!

Gain access to everything we offer!

Learn More

Divi Tutorials On YouTube

Join over 5,300 others and subscribe to our helpful Divi videos!

Visit Our Channel

Recent Posts

Pin It on Pinterest

0

Your Cart