Question

I used this plugin http://wordpress.org/extend/plugins/option-tree/ to creating some custom metaboxes.

I was trying to embed multiple Vimeo videos by using their ID. Here's how i got it displayed on the editor, - working and seems data are saved with no problems.

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 );}

However, I don't understand how to display the metabox data into a list. I'm not PHP savvy, and any help will be appreciated.

Was it helpful?

Solution

This is how I got this work, maybe this will help someone.

<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>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top