Skip to content

Instantly share code, notes, and snippets.

@johnheimkes
Forked from mustardBees/functions.php
Last active February 20, 2019 19:00
Show Gist options
  • Select an option

  • Save johnheimkes/cc1eb56be5634b7f4e5d07528f0be586 to your computer and use it in GitHub Desktop.

Select an option

Save johnheimkes/cc1eb56be5634b7f4e5d07528f0be586 to your computer and use it in GitHub Desktop.
Add &rel=0 to Youtube oembed videos
<?php
/**
* Filter YouTube oEmbed to include '&rel=0' to force channel related videos
* once video is complete, rather than showing user related videos.
*
* @param $html
* @param $url
* @param $args
*
* @return mixed
*/
public function youtubeOembedSrcAdjust( $html, $url, $args ) {
return str_replace( '?feature=oembed', '?feature=oembed&rel=0', $html );
}
add_filter( 'oembed_result', 'youtubeOembedSrcAdjust', 10, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment