-
-
Save rilwis/c2ce69c4a67a82119221 to your computer and use it in GitHub Desktop.
Meta Box Tabs and Group together
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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