Skip to content

Instantly share code, notes, and snippets.

@rilwis
Created February 24, 2015 15:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rilwis/c2ce69c4a67a82119221 to your computer and use it in GitHub Desktop.
Save rilwis/c2ce69c4a67a82119221 to your computer and use it in GitHub Desktop.
Meta Box Tabs and Group together
<?php
add_filter( 'rwmb_meta_boxes', 'prefix_register_meta_boxes' );
function prefix_register_meta_boxes( $meta_boxes )
{
$prefix = 'your_prefix_';
// 1st meta box
$meta_boxes[] = array(
'title' => __( 'Books', 'rwmb' ),
'pages' => array( 'post' ),
'tabs' => array(
'media' => 'Media Item',
'author' => 'Author',
),
'fields' => array(
array(
'id' => 'chapters',
'tab' => 'media',
'name' => __( 'Chapters', 'rwmb' ),
'type' => 'group', // Group type
'clone' => true, // Can be cloned?
// List of child fields
'fields' => array(
array(
'name' => __( 'Chapter Title', 'rwmb' ),
'id' => 'chapter_title',
'type' => 'text',
'columns' => 6, // Display child field in grid columns
),
array(
'name' => __( 'Page', 'rwmb' ),
'id' => 'page',
'type' => 'number',
'size' => 5,
'columns' => 6, // Display child field in grid columns
),
),
),
array(
'id' => 'author',
'tab' => 'author',
'name' => __( 'Authors', 'rwmb' ),
'type' => 'group', // Group type
'clone' => true, // Can be cloned?
// List of child fields
'fields' => array(
array(
'name' => __( 'Name', 'rwmb' ),
'id' => 'name',
'type' => 'text',
'columns' => 6, // Display child field in grid columns
),
array(
'name' => __( 'Email', 'rwmb' ),
'id' => 'email',
'type' => 'text',
'size' => 5,
'columns' => 6, // Display child field in grid columns
),
),
),
),
);
return $meta_boxes;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment