Hi, assuming you’re not wanting to edit the theme parts themselves, perhaps it’s a parent theme that still gets updates, then I think this code may work out for you.
add_action( 'cmb2_admin_init', function() {
$mb = cmb2_get_metabox( 'metabox_attachment' );
$mb->remove_field( 'wiki_test_repeat_group' );
}, 10 );
You’ll want to have this callback run AFTER the setup of the original metabox, so that it exists and is ready to be removed.
You’ll need to pass in the created ID value for the metabox itself into the cmb2_get_metabox() function.
From the example code I was testing with, that’d be the ID from this:
$cmb = new_cmb2_box( [
'id' => 'metabox_attachment',
'title' => 'Test',
'object_types' => [ 'post' ], // Post type
'priority' => 'high',
'show_names' => true
] );
The two fields that were added in my example code are:
$cmb->add_field( array(
'id' => 'wiki_test_repeat_group',
'type' => 'text',
'description' => __( 'Generates reusable form entries', 'cmb2' ),
'repeatable' => true,
'sortable' => true,
) );
$cmb->add_field( array(
'id' => 'wiki_test_repeat_group2',
'type' => 'text',
'description' => __( 'Wat', 'cmb2' ),
) );
so for my initial code to you above, I ran $mb->remove_field( 'wiki_test_repeat_group' );
to remove that first field, and have only the second one render and load.
Hope this helps.