我创建了一个嵌入克隆的元框:
function media( $meta_boxes ) {
$prefix = \'\';
$meta_boxes[] = array(
\'id\' => \'media_1\',
\'title\' => esc_html__( \'Media\', \'media\' ),
\'post_types\' => array( \'post\',\'personal_projects\' ),
\'context\' => \'advanced\',
\'priority\' => \'high\',
\'autosave\' => true,
\'fields\' => array(
array(
\'id\' => $prefix . \'image_advanced_2\',
\'type\' => \'image_advanced\',
\'name\' => esc_html__( \'Gallery\', \'media\' ),
),
array(
\'id\' => $prefix . \'video_1\',
\'type\' => \'video\',
\'name\' => esc_html__( \'Video\', \'media\' ),
),
array(
\'id\' => $prefix . \'oembed_1\',
\'type\'=> \'oembed\',
\'name\' => esc_html__( \'Embed Video\', \'media\' ),
\'clone\' => true,
\'add_button\' => esc_html__( \'Add video\', \'media\' ),
\'sort_clone\' => true,
),
array(
\'id\' => $prefix . \'url_1\',
\'type\' => \'url\',
\'name\' => esc_html__( \'URL\', \'media\' ),
\'clone\' => true,
),
),
);
return $meta_boxes;
}
add_filter( \'rwmb_meta_boxes\', \'media\' );
它工作得很好,只是我无法用foreach获取视频
我有一个vimeo和一个youtube视频。
$btsvideoembeds = array();
$btsvideoembeds = rwmb_meta ( \'oembed_1\', array( \'type\' => \'oembed\' ) );
foreach ( $btsvideoembeds as $btsvideoembed ) {
echo \'<div>\';
echo $btsvideoembed;
echo \'</div>\';
}
它返回的字符串不是数组