admin管理员组

文章数量:1334370

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);

本文标签: functionsHow can I grab the video id of youtube