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 に答える