Hello, @tw2113,
I’m using WordPress 5.7.1
Here is the code for registering the metaboxes:
add_action( 'cmb2_init', 'campus_register_metaboxes' );
function campus_register_metaboxes() {
// About page - TV
$about_page_team_tv = new_cmb2_box( [
'id' => $prefix.'tv_info',
'title' => esc_html__( 'TV Info ', 'campus-buzau' ),
'object_types' => [ 'page' ],
'show_on' => array( 'key' => 'page-template', 'value' => 'template-despre-noi.php' ),
'show_in_rest' => WP_REST_Server::ALLMETHODS,
] );
$about_page_team_tv->add_field( array(
'name' => 'Info',
'id' => 'tv_team_info',
'type' => 'wysiwyg',
'options' => array(),
) );
$about_team_tv = $about_page_team_tv->add_field( array(
'id' => $prefix.'tv_team_members',
'type' => 'group',
'options' => array(
'group_title' => esc_html__( 'Membru echipa TV {#}', 'campus-buzau' ), // since version 1.1.4, {#} gets replaced by row number
'add_button' => esc_html__( 'Aduaga', 'campus-buzau' ),
'remove_button' => esc_html__( 'Sterge', 'campus-buzau' ),
'sortable' => true,
'closed' => true, // true to have the groups closed by default
),
) );
$about_team_tv = $about_page_team_tv->add_field( array(
'id' => $prefix.'tv_team_members',
'type' => 'group',
'repeatable' => true,
'options' => array(
'group_title' => esc_html__( 'Membru echipa TV {#}', 'campus-buzau' ), // since version 1.1.4, {#} gets replaced by row number
'add_button' => esc_html__( 'Aduaga', 'campus-buzau' ),
'remove_button' => esc_html__( 'Sterge', 'campus-buzau' ),
'sortable' => true,
'closed' => true, // true to have the groups closed by default
),
) );
}
There are no errors in the console, I check that multiple times. I tried removing all the other metaboxes, register them again with another id and it doesn’t seem to work.
I use this specific metaboxes on a page, but only if a a specific page template is applied.
Thank you for your time, I apreciate it!