Title: remove default field from theme
Last modified: August 19, 2021

---

# remove default field from theme

 *  Resolved [newbars](https://wordpress.org/support/users/newbars/)
 * (@newbars)
 * [4 years, 9 months ago](https://wordpress.org/support/topic/remove-default-field-from-theme/)
 * Hi guys, im using a theme where their custom metabox is make with the cmb2 plugin,
   what im trying to do is to replace a few of the custom fields, i search in your
   documentation but i didn’t find a good example
 * What is the best way to do it? Maybe remove the function and added a new one 
   in my child theme?

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Contributor [Michael Beckwith](https://wordpress.org/support/users/tw2113/)
 * (@tw2113)
 * The BenchPresser
 * [4 years, 9 months ago](https://wordpress.org/support/topic/remove-default-field-from-theme/#post-14785168)
 * 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.
 *  Thread Starter [newbars](https://wordpress.org/support/users/newbars/)
 * (@newbars)
 * [4 years, 9 months ago](https://wordpress.org/support/topic/remove-default-field-from-theme/#post-14785609)
 * Works wonderful, i just had to change priority from 10 to 15 and works fine
 * Thanks so much for your help michael!
 *  Plugin Contributor [Michael Beckwith](https://wordpress.org/support/users/tw2113/)
 * (@tw2113)
 * The BenchPresser
 * [4 years, 9 months ago](https://wordpress.org/support/topic/remove-default-field-from-theme/#post-14785695)
 * Welcome.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘remove default field from theme’ is closed to new replies.

 * ![](https://ps.w.org/cmb2/assets/icon.svg?rev=2866672)
 * [CMB2](https://wordpress.org/plugins/cmb2/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/cmb2/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/cmb2/)
 * [Active Topics](https://wordpress.org/support/plugin/cmb2/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/cmb2/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/cmb2/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [Michael Beckwith](https://wordpress.org/support/users/tw2113/)
 * Last activity: [4 years, 9 months ago](https://wordpress.org/support/topic/remove-default-field-from-theme/#post-14785695)
 * Status: resolved