-
-
Save kish2011/65cd4f4fa799ff681d9cdba220b54cec to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
/** | |
* Register Team Members metabox as repeatable group fields. | |
*/ | |
function maintainn_team_members_metabox() { | |
$prefix = '_maintainn_team_'; | |
$cmb_group = new_cmb2_box( array( | |
'id' => $prefix . 'metabox', | |
'title' => __( 'Team Members', 'maintainn-demo' ), | |
'object_types' => array( 'page' ), | |
'show_on' => array( 'key' => 'page-template', 'value' => 'page-templates/full-width.php' ), | |
) ); | |
$group_field_id = $cmb_group->add_field( array( | |
'id' => $prefix . 'meta', | |
'type' => 'group', | |
'description' => '', | |
'options' => array( | |
'group_title' => __( 'Member', 'maintainn-demo' ), | |
'add_button' => __( 'Add Another Member', 'maintainn-demo' ), | |
'remove_button' => __( 'Remove', 'maintainn-demo' ), | |
'sortable' => true | |
) | |
) ); | |
$cmb_group->add_group_field( $group_field_id, array( | |
'name' => __( 'Fullname', 'maintainn-demo' ), | |
'id' => 'fullname', | |
'type' => 'text' | |
) ); | |
$cmb_group->add_group_field( $group_field_id, array( | |
'name' => __( 'Position', 'maintainn-demo' ), | |
'id' => 'position', | |
'type' => 'text', | |
) ); | |
$cmb_group->add_group_field( $group_field_id, array( | |
'name' => __( 'Photo', 'maintainn-demo' ), | |
'id' => 'photo', | |
'type' => 'file', | |
'options' => array( | |
'url' => false | |
) | |
) ); | |
} | |
add_action( 'cmb2_init', 'maintainn_team_members_metabox' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment