When you embed a video into WordPress by pasting the URL into the editor, when the clip reaches the end, YouTube will display related videos. By default, YouTube will display thumbnails for any videos it deems “related”. Sometimes, YouTube will display videos from competitors.

In any event, you don’t want visitors distracted by content from outside sources. Here is how you prevent YouTube from displaying unrelated videos.

The Old Solution

At one time, you could instruct YouTube to not display any related videos by adding a “rel=0” parameter to the URL. YouTube would run the video to the end and then stop, which was perfect.

YouTube No Longer Permits Hiding Related Videos

In September 2018, YouTube changed the rules. Now, when “rel=0” is provided as a URL parameter, they will display related videos — but, they will restrict the list videos from the same channel.

While not optimal, this is a huge improvement over having visitors see content from outside sources.

The WordPress Problem

If you embed a YouTube video in WordPress and append “?rel=0” to the URL, it makes no difference. This is because WordPress ignores all URL parameters when creating the code that embeds the video into the page.

For a time the popular solution was to install a free plugin from the WordPress repository named “Hide YouTube Related Videos” by David Hollander at SparkWeb Interactive. However, he recently removed the plugin from the repository.

The Solution

To prevent YouTube from displaying (un)related videos, all you need to do is add this code to your child theme’s functions.php file.

//Stop YouTube (Un)Related Videos
function stop_youtube_unrelated_videos($data, $url, $args = array()) {
	if (strpos($data, "feature=oembed") !== false) {
		$data = str_replace('feature=oembed', 'rel=0&feature=oembed', $data);
	return $data;
add_filter('oembed_result', 'stop_youtube_unrelated_videos', 10, 3);

If you aren’t already using a child theme, don’t make this to your theme’s functions.php file. If you do, your changes will be overwritten when you update your theme. Need help getting started with a child theme? This article is a good resource.


With just a few lines of code, you can safely and easily embed YouTube videos in your WordPress website and be confident that the only related videos displayed will be your own.

Join our email list

Join our email list

Join our mailing list to receive the latest tech tips from our team.

You have Successfully Subscribed!

Pin It on Pinterest

Share This