Title: separation example-function.php file
Last modified: April 23, 2021

---

# separation example-function.php file

 *  Resolved [theme2021](https://wordpress.org/support/users/theme2021/)
 * (@theme2021)
 * [5 years, 1 month ago](https://wordpress.org/support/topic/separation-example-function-php-file/)
 * How can I break down the code inside this file (example-function.php) ? since
   I have about 600 lines and it is difficult to find the section I need, I would
   like to split the code so that each box is in a separate file, is it possible?
    -  This topic was modified 5 years, 1 month ago by [theme2021](https://wordpress.org/support/users/theme2021/).

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

 *  Plugin Contributor [Michael Beckwith](https://wordpress.org/support/users/tw2113/)
 * (@tw2113)
 * The BenchPresser
 * [5 years, 1 month ago](https://wordpress.org/support/topic/separation-example-function-php-file/#post-14356803)
 * 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
       	) );
   
       }
       ```
   
    -  This reply was modified 5 years, 1 month ago by [Michael Beckwith](https://wordpress.org/support/users/tw2113/).
 *  Thread Starter [theme2021](https://wordpress.org/support/users/theme2021/)
 * (@theme2021)
 * [5 years, 1 month ago](https://wordpress.org/support/topic/separation-example-function-php-file/#post-14358927)
 * Thank you!
 *  Plugin Contributor [Michael Beckwith](https://wordpress.org/support/users/tw2113/)
 * (@tw2113)
 * The BenchPresser
 * [5 years, 1 month ago](https://wordpress.org/support/topic/separation-example-function-php-file/#post-14366067)
 * Welcome.

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

The topic ‘separation example-function.php file’ 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: [5 years, 1 month ago](https://wordpress.org/support/topic/separation-example-function-php-file/#post-14366067)
 * Status: resolved