Skip to content

Instantly share code, notes, and snippets.

@invmatt
Created October 14, 2013 11:28
Show Gist options
  • Select an option

  • Save invmatt/6974247 to your computer and use it in GitHub Desktop.

Select an option

Save invmatt/6974247 to your computer and use it in GitHub Desktop.
Metabox function for repeat_metabox.php
<?php
function iv_slider_metabox( array $meta_boxes ) {
$fields = array(
array( 'id' => 'iv-slider-title', 'name' => 'Text input field', 'type' => 'text' ),
array( 'id' => 'iv-slider-desc', 'name' => 'WYSIWYG field', 'type' => 'wysiwyg', 'options' => array( 'editor_height' => '100' ) ),
array( 'id' => 'iv-slider-img', 'name' => 'File field', 'type' => 'file', 'file_type' => 'image', 'repeatable' => 1, 'sortable' => 1 ),
);
/* YOU WILL NEED TO ADD THIS */
$group_fields = $fields;
foreach ( $group_fields as &$field ) {
$field['id'] = str_replace( 'field', 'gfield', $field['id'] );
}
$meta_boxes[] = array(
'title' => 'Image Slider',
'pages' => 'page',
'fields' => array(
array(
'id' => 'gp',
'name' => 'Individual slide options',
'type' => 'group',
'repeatable' => true,
'sortable' => true,
'fields' => $group_fields
)
)
);
return $meta_boxes;
}
add_filter( 'cmb_meta_boxes', 'iv_slider_metabox' );
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment