Introduction

A YouTube video URL placed in the theme’s “Video URL” field such as http://www.youtube.com/watch?v=XupTZRqFFgc&rel=0&showinfo=0 displays the video, but still shows the title and related videos.

The Solution

YouTube

This is a limitation of YouTube+WordPress (the url parameters do not work if you attempt to use the oEmbed link in the post body either).

There are two options to remedy this:

1. Use iframe embeds instead (append the URL parameters to the URL in the embed code )

OR

2. Add a custom function to your theme to append the parameters to all Youtube URLs automatically.

Adding a Custom Function (advanced users only)

This is a Mod

This is considered a modification, so do it at your own risk! Please note that we cannot assist you with modifying your theme or support problems you encounter as a result!

To add custom functions, create a new file in a plain-text or HTML editor and name it myfunctions.php. Add the following:

<?php

function remove_youtube_controls($code){
if(strpos($code, 'youtu.be') !== false || strpos($code, 'youtube.com') !== false){
$return = preg_replace("@src=(['"])?([^'">s]*)@", "src=$1$2&showinfo=0&rel=0", $code);
return $return;
}
return $code;
}

add_filter('embed_handler_html', 'remove_youtube_controls');
add_filter('embed_oembed_html', 'remove_youtube_controls');

?>

Make sure there are no extra spaces at the beginning or end, then save and upload to wp-content/themes/yourtheme/ocmx/includes/

If you are making a child theme for your theme, this function can go right into the child theme’s functions.php.

Note that this function is not guaranteed to work with the theme’s Video URL field for featured videos. If you continue to have issues, you need to use the embed method, or else add the video URL to the post body and set a featured image for the post.

Vimeo/Other

Vimeo and VideoPress links should be working fine – if you have issues hiding the title or byline, ensure your URL is entered correctly. Example:


(http://vimeo.com /57815442)?title=0&byline=0&portrait=0