1

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&playlist='.$videoID.'&';
        foreach($args as $arg => $value){
            $params .= $arg;
            $params .= '=';
            $params .= $value;
            $params .= '&';
        }
        $result = str_replace( '?version=3', $params, $html );
    }
    return $result;
}
add_filter('video_embed_html', 'imp_custom_youtube_querystring', 10, 3);

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.