我有ADDED 借助CMB2插件,使用oembed的视频元框。这是代码→
$cmb->add_field( array(
\'name\' => (\'oEmbed\'),
\'desc\' => \'Enter a youtube, twitter, or instagram URL. Supports services listed at <a href="http://codex.wordpress.org/Embeds">http://codex.wordpress.org/Embeds</a>.\',
\'id\' => $prefix . \'video_id\',
\'type\' => \'oembed\',
) );
并将其打印在主题中。我是
echoing 就像这样→
<?php
$url = esc_url( get_post_meta( get_the_ID(), \'_the_video_id\', 1 ) );
echo wp_oembed_get( $url );
?>
但我想要的是在上面的元框中(
using oembed) 应该有一个
checkbox.
我应该能够提出一个条件→
If (checkbox==true) {
<?php
$url = esc_url( get_post_meta( get_the_ID(), \'_the_video_id\', 1 ) );
echo wp_oembed_get( $url );
?>
{
$cmb->add_field( array(
\'name\' => \'Select Video or Image\',
\'desc\' => \'Select an option\',
\'id\' => $prefix . \'image_or_video\',
\'type\' => \'select\',
\'show_option_none\' => true,
\'default\' => \'custom\',
\'options\' => array(
\'standard\' => __( \'Option One\', \'cmb2\' ),
\'custom\' => __( \'Option Two\', \'cmb2\' ),
\'none\' => __( \'Option Three\', \'cmb2\' ),
),
) );
请帮助我实现这一目标→
If Option chosen is Option 2 {
Execute some PHP code
}
我的问题我该怎么写→ 如果
Option chosen 选项2是否在编程方面?