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
版权声明:本文标题:functions - How can I grab the video id of youtube? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742342677a2456914.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论