WordPress automatically handles YouTube links, which can be very helpful. However, this means you are stuck with whatever WordPress has configured, so if you want to customize how the videos are displayed – like eliminating the related video previews that display at the end of the video – you are out of luck…at least until you install this plugin.
The “Hide YouTube Related Videos” plugin by SparkWeb Interactive, Inc. will allow you to hide the related videos that display at the end. It’s simple to install (you can do so through the admin panel). After installing, just make sure to activate it, and there is nothing else to configure. It just works after you install it.
If you are not seeing the change after installing the plugin, make sure you clear the cache or do a forced refresh on the page to make sure you are getting a new copy of the content.
There is also a hyrv_extra_querystring_parameters
filter which allows you to add additional parameters to the YouTube URL. To add additional parameters to your YouTube call, click on “Plugins” and then on “Editor” in the left-hand menu bar in the WordPress admin panel. In the upper-right corner of the screen, choose “Hide YouTube Related Videos” and click “Select”.
A list of files will now be displayed on the right. Click on “hide-youtube-related-videos/hide-youtube-related-videos.php”. You’ll need to scroll down through a bit of comments, and then you’ll see a the function hide_youtube_related_videos
. You can add your additional parameters to $data. Make sure to include the HTML entity code for an ampersand to the end of it.
Here is an example where I added a color parameter to change the status bar (where it shows how much of the video you have watched) from red to white. I go in and change:
apply_filters("hyrv_extra_querystring_parameters", "wmode=transparent&")
to:
apply_filters("hyrv_extra_querystring_parameters", "wmode=transparent&color=white&")
Here is the full original code:
add_filter( 'oembed_result', 'hide_youtube_related_videos', 10, 3); function hide_youtube_related_videos($data, $url, $args = array()) { $data = preg_replace('/(youtube\.com.*)(\?feature=oembed)(.*)/', '$1?' . apply_filters("hyrv_extra_querystring_parameters", "wmode=transparent&") . 'rel=0$3', $data); return $data; }
And the full updated code:
add_filter( 'oembed_result', 'hide_youtube_related_videos', 10, 3); function hide_youtube_related_videos($data, $url, $args = array()) { $data = preg_replace('/(youtube\.com.*)(\?feature=oembed)(.*)/', '$1?' . apply_filters("hyrv_extra_querystring_parameters", "wmode=transparent&color=white&") . 'rel=0$3', $data); return $data; }
There are many parameters that you can add to modify the way the YouTube video displays and acts. You can view the full list of available parameters on the Google Developers website:
https://developers.google.com/youtube/player_parameters
Thanks for this, though it turned out I had to apply the filter to embed_oembed_html instead of oembed_result
So your code above had to be
add_filter( ”embed_oembed_html’, ‘hide_youtube_related_videos’, 10, 3);
instead of
add_filter( ‘oembed_result’, ‘hide_youtube_related_videos’, 10, 3);
Being a rookie in WP I cannot explain why. I think it may have to do with some caching of the source code.
Hello would you mind letting me know which webhost you’re utilizing?
I’ve loaded your blog in 3 different web browsers and I must
say this blog loads a lot faster then most.
Can you suggest a good internet hosting provider at a honest price?
Many thanks, I appreciate it!
I generally use SiteGround or Dreamhost if I need simple shared hosting for a WordPress blog. Both offer some nice safety features for protecting a WordPress site. SiteGround has an awesome feature where they will scan your site and send you a report letting you know it is clean. Really helpful for keeping an eye on WordPress sites. Dreamhost has a similar feature for scanning for malware on a site once a week. SiteGround also makes it really easy to install external security features like CloudFlare and such.