1

我使用这个插件http://wordpress.org/extend/plugins/option-tree/来创建一些自定义元框。

我试图使用他们的 ID 嵌入多个 Vimeo 视频。这是我在编辑器上显示它的方式, - 工作并且似乎数据保存没有问题。

add_action( 'admin_init', 'portfolio_meta_boxes' );
function portfolio_meta_boxes() {
$works_meta_box = array(
'id'        => 'works_item',
'title'     => 'Portfolio Item',
'desc'      => 'Add your portfolio item here.',
'pages'     => array( 'bkmworks' ),
'context'   => 'normal',
'priority'  => 'high',
'fields'    => array(
  array(
    'id'          => 'vimeo',
    'label'       => 'Vimeo videos',
    'desc'        => '',
    'std'         => '',
    'type'        => 'list-item',
    'rows'        => '',
    'post_type'   => '',
    'taxonomy'    => '',
    'class'       => '',
    'settings'    => array( 
      array(
        'id'          => 'vimeo_id',
        'label'       => 'Vimeo Video ID',
        'desc'        => 'Insert your Vimeo video ID. Example: https://vimeo.com/<strong>57747054</strong>. Insert only the numbers in bold.',
        'std'         => '',
        'type'        => 'text',
        'rows'        => '',
        'post_type'   => '',
        'taxonomy'    => '',
        'class'       => ''
      )
    )
  )
)); ot_register_meta_box( $works_meta_box );}

但是,我不明白如何将元框数据显示到列表中。我不精通PHP,任何帮助将不胜感激。

4

1 回答 1

3

这就是我完成这项工作的方式,也许这会对某人有所帮助。

<ul class="video-list">
<?php $repeatable_fields = get_post_meta($post->ID, 'vimeo', true); ?>
    <?php foreach ($repeatable_fields as $v) {
        echo '<li><iframe src="http://player.vimeo.com/video/' . $v['vimeo_id'] . '" width="450" height="338" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe></li>'; 
    } ?>
</ul>
于 2013-03-22T00:04:59.030 回答