Subscribe On YouTube

Join other subscribers and enjoy other Divi video tutorials!

How To Hide Related YouTube Videos In Divi

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

Note: Please be aware that the method described in this tutorial no longer hides all related YouTube videos. Instead, it now hides videos from other channels, while still displaying related videos from your own channel. This change means that you’ll only see videos related to your own content, rather than a broader range of related videos.

▶️ Please watch the video above to get all the exciting details! 👆

1. Add A Custom CSS Class To the Video Module

The first step is to add a custom CSS class to any of your video modules where you want to hide the related YouTube videos. The reason we add this class is to target specific video modules on your site.

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

add a custom css class to hide related YouTube videos in Divi

2. Add Some jQuery Code To Modify the YouTube Video URL

The second step in this tutorial to hide related YouTube videos in Divi is to add a jQuery snippet to your website. This snippet connects to the custom class added in step #1 and handles the functionality of adding a special extension to the YouTube video URL. This is what hides the related videos from other channels and only will allow YouTube to show videos from your own channel.

Where To Paste The jQuery Code

1. Divi Assistant
If you are using our Divi Assistant plugin, simply paste the code in the jQuery tab in the custom code window in the Divi Visual Builder.

2. Child Theme
If you are using a child theme, paste this code into the scripts.js file (don't forget to remove the <script> tags at the beginning and end). If you don't have a child theme, you can generate a child theme directly on your site or download our free child theme.

3. Divi Theme Options Integration
Otherwise, paste this code in your Divi>Theme Options>Integrations tab in the "Add code to the < head > of your blog" code area.

If you need help understanding where to paste the code, please check out our complete guide about where to add custom code In Divi.

<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>

OPTIONAL: Make It Global Sitewide

If you want this feature to take effect in any Divi Video module on your entire site then it’s easier to target them all at once.

This global method eliminates the need to add the custom CSS class from step #1, so if you are using this second jQuery snippet, be sure to skip step #1 above.

<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>

Subscribe For More Things Like This!

At the start of each month, we send out a recap newsletter from the month before with family news, Divi news, our latest tutorials, and product news. Occasionally, if the news is too exciting to wait, we will send out another email separate from the monthly newsletter. That’s what you get when you subscribe, and of course you can unsubscribe if you are no longer interested!

Blog Post Optin
Divi Logo (2)

Shop Our Divi Products

Plugins • Courses • Templates

Visit The Shop

Featured Products

Asset 4

New! Trail Guides

Follow a series of blog posts carefully arranged around a specific topic or goal! Keep track of your progress by marking posts completed, just like a free course!

View Trial Guides

Divi Tutorials On YouTube

Our videos have views! Join subscribers and enjoy over video tutorials!

Visit Our Channel

Leave A Response!

By commenting you agree to our Blog & YouTube Comments Policy

128 Comments

Comments By Members

These comments are highlighted because they were posted by fans who have a membership on this site.

  1. Erik Haagensen <span class="comment-author-role-label"><a href="https://www.peeayecreative.com/product/divi-adventure-club/" class="comment-author-role-link" rel="external nofollow" target="_blank">Divi Adventure Club Member</a></span>

    I saw the most comments saying it wasn’t working, but decided to give a try anyhow. It worked great! I used the global solution and pasted it in Divi Theme Options. I couldn’t believe it – actually makes the splash screen return. No related videos at all!

    Reply
  2. Karo <span class="comment-author-role-label"><a href="https://www.peeayecreative.com/product/divi-adventure-club/" class="comment-author-role-link" rel="external nofollow" target="_blank">Divi Adventure Club Member</a></span>

    Hi Nelson, I could use you rehlp because I’m really stumped – while I’m sure your code works and adds the snippet after the video links, the snippet itself it does not want to work for me – even if I add the ‘&rel=0’ in an embed code manually, I can still see the suggested videos at the end. I’ve tried Divi support but they are useless in this case and I’m at my wits end. The videos are lower on the site attached – respectively an art gallery and vineyard tour. Any ideas?

    Reply
    • Hemant Gaba <span class="comment-author-role-label"><a href="https://www.peeayecreative.com/product/divi-adventure-club/" class="comment-author-role-link" rel="external nofollow" target="_blank">Divi Adventure Club Member</a></span>

      Hi Karo!

      Thanks for reporting the issue. It seems the code is not compatible with the latest version of Divi. We’ll update it and let you know soon!

      Reply
  3. Sean Callanan <span class="comment-author-role-label"><a href="https://www.peeayecreative.com/product/divi-adventure-club/" class="comment-author-role-link" rel="external nofollow" target="_blank">Divi Adventure Club Member</a></span>

    Hate to add another “does this work?” comment – but I’m not getting the global one to work and I’m thinking maybe Google has changed things so this method no longer works? I’ll try the css class version and see if I have any more luck.

    Reply
    • Hemant Gaba <span class="comment-author-role-label"><a href="https://www.peeayecreative.com/product/divi-adventure-club/" class="comment-author-role-link" rel="external nofollow" target="_blank">Divi Adventure Club Member</a></span>

      Hi Jules!

      Are there any JS errors in the console? If not, share the URL of the page.

      Reply

Comments By Others

  1. Massimiliano Verni

    Funziona al primo colpo ! Perfetto
    Grazie, sembrava una cosa impossibile

    Reply
  2. Sue Grady

    Hello,

    I also am not able to make this work in the global option or module option.

    Reply
  3. Naomi Moon

    Thank you for this code. Your stuff usually works great.

    I tried the code in both the Divi Options Integrations and then in the child theme script.js file.
    Unfortunately, it did not work in either place for me.
    I see you fixed it on this page so perhaps there is something else that needs to be adjusted?

    Reply
  4. Eric

    Hi Divi Teacher,

    I tried to use the code above within the divi blog module but that doesn’t work there.

    What could be the adjusted query code / css class for a featured video within the blog module, sitewide?

    Thanks a lot for your website and tutorials!

    Reply
    • Hemant Gaba <span class="comment-author-role-label"><a href="https://www.peeayecreative.com/product/divi-adventure-club/" class="comment-author-role-link" rel="external nofollow" target="_blank">Divi Adventure Club Member</a></span>

      Hi Eric!

      The solution is not optimized for other modules. We will look into it further and provide a solution soon.

      Reply
  5. Graham

    Worked perfectly thank you

    Reply
  6. Scott Lindsey

    This is not working for me. Has there been an update to DIVI that prevents this from working. I have tried all. options.

    Reply
  7. Dominic

    Perhaps time for an update on this one; doesn’t work for me, and your own video is also showing related videos not from your channel. 🙂

    Reply
  8. Arnoud

    Related: how to hide the channel logo in the top left corner?
    Thanks!

    Reply
    • Hemant Gaba <span class="comment-author-role-label"><a href="https://www.peeayecreative.com/product/divi-adventure-club/" class="comment-author-role-link" rel="external nofollow" target="_blank">Divi Adventure Club Member</a></span>

      Hi Arnoud!

      That is controlled by YouTube. At this moment, they forbid removing the logo and watch us tag and the other customization which was previously possible.

      Reply
  9. Johan Linder

    Hi. Sorry, but I can not get any of these options to work.
    Tried both with the class and the global version. Related videos are still shown.

    Reply
  10. Jean

    Working well, thank you for this!

    After all those years, it’s a shame that Divi still did not add a checkbox for this option rel=0

    The article could mention the selector for the video sliders (.et_pb_video_box iframe)

    Reply
    • Hemant Gaba <span class="comment-author-role-label"><a href="https://www.peeayecreative.com/product/divi-adventure-club/" class="comment-author-role-link" rel="external nofollow" target="_blank">Divi Adventure Club Member</a></span>

      You’re welcome, glad you like it!

      We understood your query and will definitely update it in the article.

      Thank you!

      Reply
  11. Damian

    Hi, Many thanks for sharing your knowledge. At first this did not work as expected. It seems that when using lazy loading another function is needed to add &rel=0 to the data-src URL value. Now it works well. Another thought was would the ampersand need to be changed to a question mark if there were no previous embed parameters? In my case Divi had already added ?feature=oembed to both src and data-src. Cheers

    Reply
    • Hemant Gaba <span class="comment-author-role-label"><a href="https://www.peeayecreative.com/product/divi-adventure-club/" class="comment-author-role-link" rel="external nofollow" target="_blank">Divi Adventure Club Member</a></span>

      Hi Damian!

      I see what you mean. There will be multiple parameters can be added in the URL with question mark like loop, muted, etc.

      Reply
  12. Kay

    I tried many scripts and this is the only one that worked for me. Could you help with how to add a loop? Thanks a lot!

    Reply
  13. Ricky

    Hi Nelson,

    Thank you, but I found that it works at the “Edge” but failed at chrome

    Ricky

    Reply
    • Hemant Gaba <span class="comment-author-role-label"><a href="https://www.peeayecreative.com/product/divi-adventure-club/" class="comment-author-role-link" rel="external nofollow" target="_blank">Divi Adventure Club Member</a></span>

      Hey Ricky,

      I have checked the website and it’s working for me in chrome as well. Could you please check it again and let me know how it goes?

      Reply
  14. Angie

    Thank you so much! This works great!

    Reply
  15. Dominic

    Lifesaver. worked beautifully as of today. 🙂

    Reply
  16. Bas

    Hi there, I don’t want any suggestion. I just want the option to play the video again and nothing else. How can i do that?
    Thanks!

    Reply
    • Hemant Gaba <span class="comment-author-role-label"><a href="https://www.peeayecreative.com/product/divi-adventure-club/" class="comment-author-role-link" rel="external nofollow" target="_blank">Divi Adventure Club Member</a></span>

      Hey Bas,

      You always get a replay button in the bottom left corner beside the volume icon. Is that what you are referring to?

      Reply
  17. STEPHEN CURRIE

    Maybe I’m late to the party, but I see the article was updated in Jan 2021, so fingers crossed for some input. I have tried this using and sadly cannot get it working. The JS is not injecting the rel=0 on page load. If I open my console, and paste the JS and run it, it works, but not on the page load. Stumped

    Reply
    • David

      Yeah – same exact problem. Works on the console but not from Divi’s integration fields. It IS injected into the page but doesn’t seem to fire. I can copy into the console and it runs and works. Strange

      Reply
      • David

        I got this version of the code to work for Divi’s video module when the other would not:

        jQuery(document).ready(function($ ) {
        // using Divi’s video modules
        var videourl = $(‘.et_pb_video_box iframe’).attr( “src”);
        var videourl = videourl + `&rel=0`;
        $(‘.et_pb_video_box iframe’).attr( “src”,videourl);
        });

    • Hemant Gaba <span class="comment-author-role-label"><a href="https://www.peeayecreative.com/product/divi-adventure-club/" class="comment-author-role-link" rel="external nofollow" target="_blank">Divi Adventure Club Member</a></span>

      Hi Stephen,

      I am afraid that I am not able to replicate the issue on my end as everything is working just fine. Please make sure to follow all the steps given in the guide properly.

      Reply
  18. Matt Wilson

    The “global” solution should be updated to include the Video Slider module, too. Simply change “.et_pb_video” to “.et_pb_video_box” since the slider and standard video module both contain the same child element. Thanks for the great solution!

    Reply
  19. Romain

    Works great! Thanks so much !!

    Reply
  20. Fanny

    Hello Nelson, I can’t tell you how many times I am coming back to this post. It works awesome!

    Reply
  21. Adam

    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.

    Reply
  22. Fanny

    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?

    Reply
  23. charlie

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

    Reply
  24. photoMaldives

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

    Reply
  25. Erick Fabian

    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.

    Reply
    • Matt Wilson

      To make this jQuery work on both the Slider and Standard video modules, use the class name “.et_pb_video_box” instead of “.et_pb_video” as provided in the original sample.

      jQuery(document).ready(function($ ) {
      $(‘.et_pb_video_box iframe’).attr( “src”, function( i, val ) {
      return val + ‘&rel=0’;
      });
      });

      Reply
      • Christine Olson

        I know I’m late to the party here, but I just needed this today, on a video slider module. Matt, your change worked perfectly for me. Thank you very much, and thank you, Nelson!

      • Erick Fabian

        Thanks still for all your work.

  26. Arquímedes

    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.

    Reply
  27. Mike

    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.

    Reply
  28. CJ

    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 🙂

    Reply
  29. Matt

    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.

    Reply
    • Nelson Lee Miller (aka The Divi Teacher) <span class="comment-author-role-label author-label">Author</span>

      Hi Matt,
      That’s now how it is for me. It definitely only shows my videos even if logged out or incognito. Also there is nothing in the code that would cause that. It’s a nice suggestion, but I don’t have any evidence of it from my end!

      Reply
  30. ben

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

    Reply
  31. Sylvain Breton

    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!

    Reply
      • Sylvain Breton

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

  32. Ingrid

    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…

    Reply
  33. Peter Thompson

    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.

    Reply
  34. Ross

    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.

    Reply
      • jp

        Of course you can’t, since you’re using adblock. If you disable adblock, you will see related videos because rel=”0″ has been down for a long time. I use my own plug which covers this garbage.

  35. Taisa

    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.

    Reply
  36. Aniket Joshi

    Does this work for the code module?

    Reply
      • 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?

  37. Anna

    Worked perfectly! Thank you so much, Nelson. 🙂

    Reply
  38. Sigi

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

    Reply
      • 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!

      • Nelson Lee Miller (aka The Divi Teacher) <span class="comment-author-role-label author-label">Author</span>

        Hi Ayush,
        Yes, this is the best we can do due to YouTube’s limitations. In the past we could remove them completely, but now the best we can do is show videos from your own channel.

  39. darryl

    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

    Reply
  40. Kelly

    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!

    Reply
    • Nelson Lee Miller (aka The Divi Teacher) <span class="comment-author-role-label author-label">Author</span>

      Hi Kelly,
      I think you are referring to an embed code. I haven’t tried that, but I would use a code module, not a text module. It should work, but I really can’t say without trying it.

      Reply
  41. Guillermo

    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!

    Reply
      • 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

  42. Meg

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

    Reply
      • Meg

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

  43. Lisa Roberts

    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!!

    Reply
  44. Dan Palmer

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

    Reply
  45. Frederick D.

    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!

    Reply
    • Nelson Lee Miller (aka The Divi Teacher) <span class="comment-author-role-label author-label">Author</span>

      Hey Frederick,
      Thank you so much for your comments! I’m very happy you found this. I will certainly keep them coming and have lots planned and scheduled! Let me know if you have suggestions!

      Reply
  46. Elisandro Borges

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

    Reply
    • Daniel

      Thanks a lot its work. How can I hide yt share/copy link button please?
      Thank You

      Reply
      • Elisandro Fernandes Borges

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

  47. Cliff

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

    Reply
  48. Maciej

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

    Reply
  49. Olga

    This doesn’t seem to work

    Reply

Submit a Comment

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

Recent Posts

Shopping cart0
There are no products in the cart!
You may be interested in…
$19.00$22.50

Select options This product has multiple variants. The options may be chosen on the product page

$16.50$24.00

Select options This product has multiple variants. The options may be chosen on the product page

$16.50$24.00

Select options This product has multiple variants. The options may be chosen on the product page

$19.00$24.00

Select options This product has multiple variants. The options may be chosen on the product page

$20.50$24.00

Select options This product has multiple variants. The options may be chosen on the product page

Graphic showcasing Divi Assistant features and toolset.
From: $69.00 / year

Select options This product has multiple variants. The options may be chosen on the product page

Divi Search Helper Plugin By Pee Aye Creative
From: $29.00 / year

Select options This product has multiple variants. The options may be chosen on the product page

Continue shopping
0