All Collections
Divi Documentation
Customizing Divi
How to prevent the Video Module from showing General Public YouTube related Videos to be displayed after a video was played
How to prevent the Video Module from showing General Public YouTube related Videos to be displayed after a video was played

After a YouTube video plays, it will show that other videos are related to the video that was just played.

Eduard Ungureanu avatar
Written by Eduard Ungureanu
Updated over a week ago

Each time we use the Video module to display a specific video from YouTube, once it is done playing, at the end, YouTube will automatically show other related videos.

We can stop that behavior using a custom JS code.

Before writing any JS code, edit the Video Module and in Advanced Tab > CSS ID & Classes > CSS Class, type in divi-no-yt-related-videos.

This will be a CSS class that we will be using in the following JS code.

<script id="remove-related-youtube-videos">
(function ($) {
$(document).ready(function () {
if ($('.divi-no-yt-related-videos').length) {
$('.divi-no-yt-related-videos iframe').attr('src', function (i, val) {
return val + '&rel=0';
});
}
});
})(jQuery);
</script>

The jQuery code can be copied/pasted into Divi > Theme Option > Integration tab > Header.

Important Note: The above code will show only related videos from the same channel as the video just played.

If the video used in the video module is not part of a channel, the rel=0 attribute will still display any relevant, public video at the end of your video.

Did this answer your question?