you don’t need to create all your metaboxes in one single callback to cmb2_admin_init
. You could create one callback per file, that has just one metabox invocation each.
first_file.php
add_action( 'cmb2_admin_init', 'yourprefix_register_first' );
function yourprefix_register_first() {
$cmb_term = new_cmb2_box( array(
'id' => 'yourprefix_term_edit',
'title' => esc_html__( 'Category Metabox', 'cmb2' ), // Doesn't output for term boxes
'object_types' => array( 'term' ), // Tells CMB2 to use term_meta vs post_meta
'taxonomies' => array( 'category', 'post_tag' ), // Tells CMB2 which taxonomies should have these fields
// 'new_term_section' => true, // Will display in the "Add New Category" section
) );
}
second_file.php
add_action( 'cmb2_admin_init', 'yourprefix_register_second' );
function yourprefix_register_second() {
$cmb_term = new_cmb2_box( array(
'id' => 'yourprefix_term_edit',
'title' => esc_html__( 'Category Metabox', 'cmb2' ), // Doesn't output for term boxes
'object_types' => array( 'term' ), // Tells CMB2 to use term_meta vs post_meta
'taxonomies' => array( 'category', 'post_tag' ), // Tells CMB2 which taxonomies should have these fields
// 'new_term_section' => true, // Will display in the "Add New Category" section
) );
}
third_file.php
add_action( 'cmb2_admin_init', 'yourprefix_register_third' );
function yourprefix_register_third() {
$cmb_term = new_cmb2_box( array(
'id' => 'yourprefix_term_edit',
'title' => esc_html__( 'Category Metabox', 'cmb2' ), // Doesn't output for term boxes
'object_types' => array( 'term' ), // Tells CMB2 to use term_meta vs post_meta
'taxonomies' => array( 'category', 'post_tag' ), // Tells CMB2 which taxonomies should have these fields
// 'new_term_section' => true, // Will display in the "Add New Category" section
) );
}