How can I grab the video id of youtube?
I tried $videoID = wp_oembed_get( get_post_meta( get_the_ID(), 'video_url', true ) );
but that doesn't seem to do anything. I'm trying to set playlist id as the video id so the video loops itself.
function imp_custom_youtube_querystring( $html ) {
if(strpos($html, 'youtube')!= FALSE) {
$args = [
'rel' = 0,
'showinfo' = 0,
'modestbranding' = 1,
'loop' = 1,
];
$videoID = wp_oembed_get( get_post_meta( get_the_ID(), 'video_url', true ) );
$params = '?version=3#038;playlist='.$videoID.'#038;';
foreach($args as $arg = $value){
$params .= $arg;
$params .= '=';
$params .= $value;
$params .= '#038;';
}
$result = str_replace( '?version=3', $params, $html );
}
return $result;
}
add_filter('video_embed_html', 'imp_custom_youtube_querystring', 10, 3);