skip to Main Content

Add Custom Parameters to Youtube Video oEmbeds

Many functions in the theme use the WordPress oEmbed function which "strips" parameters from the URL. To add the parameters you must use a custom field via a child theme to override the output such as the example below:

add_filter( 'embed_oembed_html', function( $cache, $url, $attr, $post_ID ) {
	
	// Modify youtube params
	if ( strstr( $cache, 'youtube.com/embed/' ) ) {
		$cache = str_replace( '?feature=oembed', '?rel=0&modestbranding=1&autohide=1&showinfo=0&controls=0', $cache );
	}
	
	// Return oEmbed html
	return $cache;

}, 10, 4 );
All PHP snippets should be added via child theme's functions.php file or via a plugin (we recommend Code Snippets)
Back To Top