Title: admin array and header error
Last modified: September 4, 2020

---

# admin array and header error

 *  Resolved [EliWbbr](https://wordpress.org/support/users/eliwbbr/)
 * (@eliwbbr)
 * [5 years, 9 months ago](https://wordpress.org/support/topic/admin-array-and-header-error/)
 * I’m getting two errors in the wp admin that are relating to the cmb2 lib (which
   i LOVE, by the way). Here are the errors:
 * >  Notice: Array to string conversion in ../themes/patk_nickell/cmb2/includes/
   > CMB2_Hookup.php on line 141
   > Warning: Cannot modify header information – headers already sent by (output
   > started at ../themes/patk_nickell/cmb2/includes/CMB2_Hookup.php:141) in ../
   > staging21.thestudio-patrick.com/public_html/wp-includes/functions.php on line
   > 6270
 * I _think_ it related to the file field type. Because on the page you can see 
   this code above that file upload field input box:
 * >  Notice: Undefined offset: 1 in ../wp-content/themes/patk_nickell/cmb2/includes/
   > types/CMB2_Type_File_Base.php on line 146
   > Notice: A non well formed numeric value encountered in ../wp-includes/media.
   > php on line 445
   > Notice: Undefined offset: 1 in ../wp-content/themes/patk_nickell/cmb2/includes/
   > CMB2_Utils.php on line 145
   > Notice: A non well formed numeric value encountered in ../wp-content/themes/
   > patk_nickell/cmb2/includes/CMB2_Utils.php on line 152
   > Notice: Undefined offset: 1 in ../wp-content/themes/patk_nickell/cmb2/includes/
   > CMB2_Utils.php on line 137
   > Notice: A non well formed numeric value encountered in ../public_html/wp-includes/
   > media.php on line 445
   > Notice: Undefined offset: 1 in ../wp-content/themes/patk_nickell/cmb2/includes/
   > CMB2_Utils.php on line 145
   > Notice: A non well formed numeric value encountered in ../wp-content/themes/
   > patk_nickell/cmb2/includes/CMB2_Utils.php on line 152
   > Notice: Undefined offset: 1 in ../wp-content/themes/patk_nickell/cmb2/includes/
   > CMB2_Utils.php on line 137
   > Notice: A non well formed numeric value encountered in ../public_html/wp-includes/
   > media.php on line 445
   > Notice: Undefined offset: 1 in ../wp-content/themes/patk_nickell/cmb2/includes/
   > CMB2_Utils.php on line 145
   > Notice: A non well formed numeric value encountered in ../wp-content/themes/
   > patk_nickell/cmb2/includes/CMB2_Utils.php on line 152
   > Notice: Undefined offset: 1 in ../wp-content/themes/patk_nickell/cmb2/includes/
   > CMB2_Utils.php on line 137
   > Notice: A non well formed numeric value encountered in ../public_html/wp-includes/
   > media.php on line 445
   > Notice: Undefined offset: 1 in ../wp-content/themes/patk_nickell/cmb2/includes/
   > CMB2_Utils.php on line 145
   > Notice: A non well formed numeric value encountered in ../wp-content/themes/
   > patk_nickell/cmb2/includes/CMB2_Utils.php on line 152
   > Notice: Undefined offset: 1 in ../wp-content/themes/patk_nickell/cmb2/includes/
   > CMB2_Utils.php on line 137
   > Notice: A non well formed numeric value encountered in ../public_html/wp-includes/
   > media.php on line 445
   > Notice: Undefined offset: 1 in ../wp-content/themes/patk_nickell/cmb2/includes/
   > CMB2_Utils.php on line 145
   > Notice: A non well formed numeric value encountered in ../wp-content/themes/
   > patk_nickell/cmb2/includes/CMB2_Utils.php on line 152
   > Notice: Undefined offset: 1 in ../wp-content/themes/patk_nickell/cmb2/includes/
   > CMB2_Utils.php on line 168
 * I searched all over stack overflow and your cmb2 documentation without any real
   success. I downloaded the lateset from github and set up the lib on WP 5.5.1 
   site on an Apache server with PHP 7.3.20 earlier today when i was updating some
   other scripts.
 * Can you offer any advice? I’ll be glad to share my code if you need to see that.
 * Here are images: [Pic 1](https://staging21.thestudio-patrick.com/images/1.png)
   [Pic 2](https://staging21.thestudio-patrick.com/images/2.png)
 * Thanks in advance!
    -  This topic was modified 5 years, 9 months ago by [EliWbbr](https://wordpress.org/support/users/eliwbbr/).
    -  This topic was modified 5 years, 9 months ago by [EliWbbr](https://wordpress.org/support/users/eliwbbr/).
    -  This topic was modified 5 years, 9 months ago by [EliWbbr](https://wordpress.org/support/users/eliwbbr/).
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fadmin-array-and-header-error%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 15 replies - 1 through 15 (of 20 total)

1 [2](https://wordpress.org/support/topic/admin-array-and-header-error/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/admin-array-and-header-error/page/2/?output_format=md)

 *  Plugin Contributor [Michael Beckwith](https://wordpress.org/support/users/tw2113/)
 * (@tw2113)
 * The BenchPresser
 * [5 years, 9 months ago](https://wordpress.org/support/topic/admin-array-and-header-error/#post-13363857)
 * Can you provide your CMB2 configuration as well?
 * Here’s what’s on line 141 of CMB2_Hookup, and likely refers to that `$post_type`:
 *     ```
       add_filter( "manage_{$post_type}_posts_columns", array( $this, 'register_column_headers' ) );
       ```
   
 * All the rest of the notices appear to be related to media files and not having
   arrays at the expected size.
 *  Thread Starter [EliWbbr](https://wordpress.org/support/users/eliwbbr/)
 * (@eliwbbr)
 * [5 years, 9 months ago](https://wordpress.org/support/topic/admin-array-and-header-error/#post-13364092)
 * You bet, here you go:
 * >  /*** Define the metabox and field configurations. */
   >  function cmb2_metaboxes(){
   > // Start with an underscore to hide fields from custom fields list
   >  $prefix
   > = ‘_cmb2_’; /* —————————————————————————–*/ /* */ /* Initiate MASTHEAD IMAGE
   > the metabox */ /* */ /* —————————————————————————–*/ $cmb = new_cmb2_box( array(‘
   > id’ => ‘masthead_fileupload’, ‘title’ => __( ‘Masthead’, ‘cmb2’ ), ‘object_types’
   > => array( ‘page’, (array (‘post’, ‘product’)) ), // Post type ‘context’ => ‘
   > normal’, ‘priority’ => ‘high’, ‘show_names’ => true, // Show field names on
   > the left ‘cmb_styles’ => true, // false to disable the CMB stylesheet // ‘closed’
   > => true, // Keep the metabox closed by default ) );
   >  $cmb->add_field( array(
   >  ‘name’ => __( ‘Masthead Image’, ‘cmb2’ ), ‘desc’ 
   > => __( ‘Upload a masthead image this page. If nothing is selected, a default
   > image will be used.’, ‘cmb2’ ), ‘id’ => $prefix . ‘masthead_image’, ‘type’ 
   > => ‘file’, ‘preview_size’ => array( ‘100, 100’ ), // Default: array( 50, 50)));
   > }
 * And here is how i’m trying to pull it into the front end:
 * >  <!– Masthead Banner –>
   > <!– foreach ( (array) $locations as $key => $location ) –>
   >  <?php $masthead_imgs
   > = get_post_meta(get_the_ID(), ‘_cmb2_masthead_image’, true); //$masthead_imgs
   > = wp_get_attachment_image( get_post_meta( get_the_ID(), ‘_cmb2_masthead_image’,
   > 1 ), ‘medium’ ); if( !empty ($masthead_imgs)) { ?>
   >  <section id=”<?php the_id(); ?>”
   >  data-type=”background” data-speed=”15″ style
   > =”border:1px solid blue;background: url("<?php foreach( (array) $masthead_imgs
   > as $masthead) { echo $masthead; } ?>") 50% 0 / cover repeat fixed; min-height:
   > 320px; height: 100%; width: 100%; position: relative;”> </section>
   >  <?php } else { ?>
   >  <section id=”<?php the_id(); ?>”
   >  data-type=”background” data-speed=”10″ style
   > =”border:1px solid red; background: url(‘<?php bloginfo(‘template_directory’);?
   > >/img/masthead.jpg’) 50% 0 / cover repeat fixed; min-height: 320px; height:
   > 100%; width: 100%; position: relative;”> </section>
   > <?php } ?>
 * Hope that helps, please let me know if you would like anything else!
 * Thanks for the continued support! 🙂
 *  Plugin Contributor [Michael Beckwith](https://wordpress.org/support/users/tw2113/)
 * (@tw2113)
 * The BenchPresser
 * [5 years, 9 months ago](https://wordpress.org/support/topic/admin-array-and-header-error/#post-13364150)
 * This part looks the most off:
 *     ```
       ‘object_types’ => array( ‘page’, (array (‘post’, ‘product’)) ), // Post type
       ```
   
 * Followed by this:
 *     ```
        array( ‘100, 100’ )
       ```
   
 * You should be able to be just fine using this for the first item:
 *     ```
       ‘object_types’ => array( ‘page’, ‘post’, ‘product’ ), // Post type
       ```
   
 * The second item is thinking it only has 1 index passed, due to the quotes. You’ll
   see in your pasted example above that it doesn’t use any quotes, so this should
   work and provide the 2 indexes it’s expecting
 *     ```
        array( 100, 100 )
       ```
   
 *  Thread Starter [EliWbbr](https://wordpress.org/support/users/eliwbbr/)
 * (@eliwbbr)
 * [5 years, 9 months ago](https://wordpress.org/support/topic/admin-array-and-header-error/#post-13368246)
 * Hello Mr Beckwith,
    Thank you for your suggestions. I made them. And tested the
   front end. And it worked as it should, there is an image loaded into that page
   on the admin. Then I tried logging into the back end to see if removing the image
   form the metabox would prompt a predetermined image to appear. But i can’t seem
   to get into the wp admin at all now..? Here is a screen shot: [https://staging21.thestudio-patrick.com/images/cannot-access-admin.jpg](https://staging21.thestudio-patrick.com/images/cannot-access-admin.jpg)
 * Hope you can help again!
 * Thank you in advance!!
 *  Plugin Contributor [Michael Beckwith](https://wordpress.org/support/users/tw2113/)
 * (@tw2113)
 * The BenchPresser
 * [5 years, 9 months ago](https://wordpress.org/support/topic/admin-array-and-header-error/#post-13369185)
 * Seems like [https://plugins.trac.wordpress.org/browser/cmb2/trunk/includes/CMB2_Hookup.php#L140](https://plugins.trac.wordpress.org/browser/cmb2/trunk/includes/CMB2_Hookup.php#L140)
   is still somehow receiving an array instead of a string.
 * Can you try reducing the `object_types` parameter down to just 1 index, say `
   array( ‘page’ )`
 * Also, just in case, do you have other metaboxes that you’re registering but perhaps
   not trying to debug that have a similar `‘object_types’ => array( ‘page’, (array(‘
   post’, ‘product’)) ), // Post type` setup?
 *  Thread Starter [EliWbbr](https://wordpress.org/support/users/eliwbbr/)
 * (@eliwbbr)
 * [5 years, 9 months ago](https://wordpress.org/support/topic/admin-array-and-header-error/#post-13382636)
 * Good morning!
    Thank you for your response. i do have another field i’m using
   multiple parameters for:
 * >  /* —————————————————————————–*/
   >  /* */ /* Initiate MASTHEAD SUBHEADING the
   > metabox */ /* */ /* —————————————————————————–*/ $cmb = new_cmb2_box( array(‘
   > id’ => ‘masthead_subhead_metabox’, ‘title’ => __( ‘Masthead Subheading’, ‘cmb2’),‘
   > object_types’ => array( ‘page’, (array (‘post’, ‘product’)) ), // Post type‘
   > context’ => ‘normal’, ‘priority’ => ‘high’, ‘show_names’ => true, // Show field
   > names on the left ‘cmb_styles’ => true, // false to disable the CMB stylesheet//‘
   > closed’ => true, // Keep the metabox closed by default ) ); $cmb->add_field(
   > array( ‘name’ => __( ‘Sub-heading’, ‘cmb2’ ), ‘desc’ => __( ‘Enter a sub-heading
   > for this page (optional)’, ‘cmb2’ ), ‘id’ => $prefix . ‘masthead_subhead’, ‘
   > type’ => ‘text’, ‘column’ => array( ‘position’ => 5 ), ) );
 * Though i never noticed any issues with text field.
 * Per your suggestions above, i’ve limited the object_types to just pages:
 * >  /* —————————————————————————–*/
   >  /* */ /* Initiate MASTHEAD IMAGE the metabox*//**//*—————————————————————————–*/
   > $cmb = new_cmb2_box( array( ‘id’ => ‘masthead_fileupload’, ‘title’ => __( ‘
   > Masthead’, ‘cmb2’ ), ‘object_types’ => array( ‘page’ ), // Post type ‘context’
   > => ‘normal’, ‘priority’ => ‘high’, ‘show_names’ => true, // Show field names
   > on the left ‘cmb_styles’ => true, // false to disable the CMB stylesheet //‘
   > closed’ => true, // Keep the metabox closed by default ) );
   >  $cmb->add_field( array(
   >  ‘name’ => __( ‘Masthead Image’, ‘cmb2’ ), ‘desc’ 
   > => __( ‘Upload a masthead image this page. If nothing is selected, a default
   > image will be used.’, ‘cmb2’ ), ‘id’ => $prefix . ‘masthead_image’, ‘type’ 
   > => ‘file’, ‘preview_size’ => array( 100, 100 ), // Default: array( 50, 50 )));
 * Hope this helps. Thanks so much for your continued help!! 🙂
 *  Plugin Contributor [Michael Beckwith](https://wordpress.org/support/users/tw2113/)
 * (@tw2113)
 * The BenchPresser
 * [5 years, 9 months ago](https://wordpress.org/support/topic/admin-array-and-header-error/#post-13383192)
 * Did that resolve the shown errors and whatnot?
 *  Thread Starter [EliWbbr](https://wordpress.org/support/users/eliwbbr/)
 * (@eliwbbr)
 * [5 years, 9 months ago](https://wordpress.org/support/topic/admin-array-and-header-error/#post-13383340)
 * Unfortunately it did not :/
 *  Plugin Contributor [Michael Beckwith](https://wordpress.org/support/users/tw2113/)
 * (@tw2113)
 * The BenchPresser
 * [5 years, 9 months ago](https://wordpress.org/support/topic/admin-array-and-header-error/#post-13383411)
 * Do you have OTHER spots where you’re creating more metaboxes that are maybe done
   the same way as you originally had, with the nested object type specifications?
   Look through all of your metabox configs, if you have more than just this one.
 *  Thread Starter [EliWbbr](https://wordpress.org/support/users/eliwbbr/)
 * (@eliwbbr)
 * [5 years, 8 months ago](https://wordpress.org/support/topic/admin-array-and-header-error/#post-13438850)
 * Sorry for the delay, i got pulled onto another project. Hopefully we can continue
   here. I still cannot log into wp-admin the error reads:
 * >  **Notice: Array to string conversion in** /../../../../../wp-content/themes/
   > patk_nickell/cmb2/includes/CMB2_Hookup.php on line 141
   >  <br /> Warning: Cannot
   > modify header information – headers already sent by (output started at /../../../../../
   > wp-content/themes/patk_nickell/cmb2/includes/CMB2_Hookup.php:141) in /../../../../../
   > wp-includes/pluggable.php on line 1296
 * I do not have any multiple object types; they are either for a specific page 
   or a specific posttype. I can provide if you like.
 * Let me know what you think. And thanks so much for the continued help!
 *  Plugin Contributor [Michael Beckwith](https://wordpress.org/support/users/tw2113/)
 * (@tw2113)
 * The BenchPresser
 * [5 years, 8 months ago](https://wordpress.org/support/topic/admin-array-and-header-error/#post-13439187)
 * At this point, I’m basically interested in seeing the code for every time you
   initialize this in your theme:
 *     ```
       $variable = new_cmb2_box( array(
       ...
       ) );
       ```
   
 * Because somehow, in this code from CMB2_Hookup.php, the $post_type is ending 
   up an array and we need it to be a string.
 *     ```
       foreach ( $this->cmb->box_types() as $post_type ) {
       	add_filter( "manage_{$post_type}_posts_columns", array( $this, 'register_column_headers' ) );
       ```
   
 *  Thread Starter [EliWbbr](https://wordpress.org/support/users/eliwbbr/)
 * (@eliwbbr)
 * [5 years, 8 months ago](https://wordpress.org/support/topic/admin-array-and-header-error/#post-13439249)
 *     ```
       <?php
       /**
        * Include and setup custom metaboxes and fields. (make sure you copy this file to outside the CMB2 directory)
        *
        * Be sure to replace all instances of 'products_' with your project's prefix.
        * http://nacin.com/2010/05/11/in-wordpress-prefix-everything/
        *
        * @category YourThemeOrPlugin
        * @package  Demo_CMB2
        * @license  http://www.opensource.org/licenses/gpl-license.php GPL v2.0 (or later)
        * @link     https://github.com/WebDevStudios/CMB2
        */
   
       /**
        * Get the bootstrap! If using the plugin from wordpress.org, REMOVE THIS!
        */
   
       if ( file_exists( dirname( __FILE__ ) . '/cmb2/init.php' ) ) {
       	require_once dirname( __FILE__ ) . '/cmb2/init.php';
       } elseif ( file_exists( dirname( __FILE__ ) . '/CMB2/init.php' ) ) {
       	require_once dirname( __FILE__ ) . '/CMB2/init.php';
       }
       add_action( 'cmb2_init', 'cmb2_metaboxes' );
       /*** Define the metabox and field configurations.  */
       function cmb2_metaboxes() {
   
       // Start with an underscore to hide fields from custom fields list
       $prefix = '_cmb2_';
   
       /* -----------------------------------------------------------------------------*/
       /*                                                                              */
       /*  Initiate NEW! POPUP the metabox    */
       /*                                                                              */
       /* -----------------------------------------------------------------------------*/
       //$cmb = new_cmb2_box( array(
       //	'id'            => 'homepage_popup',
       //	'title'         => __( 'Home page Pop-up', 'cmb2' ),
       //	'object_types'  => array( 'post', 'product' ), // Post type
       //	'context'       => 'side',
       //	'priority'      => 'high',
       //	'show_names'    => true, // Show field names on the left
       //	'cmb_styles' 	=> true, // false to disable the CMB stylesheet
       //	// 'closed'     => true, // Keep the metabox closed by default
       //) );
       //    $cmb->add_field( array(
       //        'name' 			=> 'Is this a Pop-up item?',
       //        'desc' 			=> 'Ceck this box if you want a pop-up on the homepage',
       //        'id'   			=> $prefix . 'popup_checkbox',
       //        'type' 			=> 'checkbox',
       //    ) );
   
   
   
       /* -----------------------------------------------------------------------------*/
       /*                                                                              */
       /*  Initiate MASTHEAD SUBHEADING the metabox    */
       /*                                                                              */
       /* -----------------------------------------------------------------------------*/
       $cmb = new_cmb2_box( array(
       	'id'            => 'masthead_subhead_metabox',
       	'title'         => __( 'Masthead Subheading', 'cmb2' ),
       	'object_types'  => array( 'page' ), // Post type (array ('post', 'product'))
       	'context'       => 'normal',
       	'priority'      => 'high',
       	'show_names'    => true, // Show field names on the left
       	'cmb_styles' 	=> true, // false to disable the CMB stylesheet
       	// 'closed'     => true, // Keep the metabox closed by default
       ) );
           $cmb->add_field( array(
                   'name'         => __( 'Sub-heading', 'cmb2' ), 
                   'desc'         => __( 'Enter a sub-heading for this page (optional)', 'cmb2' ),
                   'id'           => $prefix . 'masthead_subhead',
                   'type'         => 'text',
                   'column' => array( 'position' => 5 ),
           ) );    
   
   
   
       /* -----------------------------------------------------------------------------*/
       /*                                                                              */
       /*  Initiate MASTHEAD IMAGE the metabox    */
       /*                                                                              */
       /* -----------------------------------------------------------------------------*/
       $cmb = new_cmb2_box( array(
       	'id'            => 'masthead_fileupload',
       	'title'         => __( 'Masthead', 'cmb2' ),
       	'object_types'  => array( 'page' ), // Post type
       	'context'       => 'normal',
       	'priority'      => 'high',
       	'show_names'    => true, // Show field names on the left
       	'cmb_styles' 	=> true, // false to disable the CMB stylesheet
       	// 'closed'     => true, // Keep the metabox closed by default
       ) );
   
       		$cmb->add_field( array(
       				'name'         => __( 'Masthead Image', 'cmb2' ),
       				'desc'         => __( 'Upload a masthead image this page. If nothing is selected, a default image will be used.', 'cmb2' ),
       				'id'           => $prefix . 'masthead_image',
       				'type'         => 'file',
       				'preview_size' => array( 100, 100 ), // Default: array( 50, 50 )
       		) );		
   
   
   
       /* -----------------------------------------------------------------------------*/
       /*                                                                              */
       /*  Initiate PRODUCTS the metabox    */
       /*                                                                              */
       /* -----------------------------------------------------------------------------*/
       $cmb = new_cmb2_box( array(
       	'id'            => 'products_metabox',
       	'title'         => __( '<h1 class="patk_cmb2_h1">Products</h1>', 'cmb2' ),
       	'object_types'  => array( 'post', 'product' ), // Post type
       	'context'       => 'normal',
       	'priority'      => 'high',
       	'show_names'    => true, // Show field names on the left
       	'cmb_styles' 	=> true, // false to disable the CMB stylesheet
       	// 'closed'     => true, // Keep the metabox closed by default
       ) );
   
       		$cmb->add_field( array(
                       'name'         => __( 'Finish', 'cmb2' ), 
                       'desc'         => __( 'Enter a finish for this product', 'cmb2' ),
                       'id'           => $prefix . 'finish',
                       'type'         => 'text',
                       //'column' => array( 'position' => 5 ),
       		) );
       		$cmb->add_field( array(
       				'name'    		=> 'Species',
       				'desc'    		=> __('Enter the species of wood for this product', 'cmb2'),
       				'id'      		=> $prefix . 'species',
       				'type'    		=> 'text',
       				//'column' 		=> array( 'position' => 7 ),
       		) );
       		$cmb->add_field( array(
       				'name' 			=> 'Grade',
       				'desc' 			=> 'Enter the grade of this product',
       				'id' 			=> $prefix . 'grade',
       				'type' 			=> 'text'
       		) );    
       		$cmb->add_field( array(
       				'name' 			=> 'Average Box Qty',
       				'desc' 			=> 'Enter the average box quantity of this product',
       				'id' 			=> $prefix . 'avg_box_qty',
       				'type' 			=> 'text'
       		) );        
       		$cmb->add_field( array(
       				'name' 			=> 'Length',
       				'desc' 			=> 'Enter the length of this product',
       				'id' 			=> $prefix . 'length',
       				'type' 			=> 'text',
                       'column' 		=> array( 'position' => 5 ),
       		) );            
       		$cmb->add_field( array(
       				'name' 			=> 'Rabbet',
       				'desc' 			=> 'Enter the rabbet depth for this product',
       				'id' 			=> $prefix . 'rabbet',
       				'type' 			=> 'text',
                       'column' 		=> array( 'position' => 6 ),
       		) );                
               $cmb->add_field( array(
       				'name'         => __( 'Large Image', 'cmb2' ),
       				'desc'         => __( 'Upload a large image this product for customers to see detail.', 'cmb2' ),
       				'id'           => $prefix . 'large_image',
       				'type'         => 'file',
       				'preview_size' => array( 100, 100 ), // Default: array( 50, 50 )
                       'column'        => array('position' => 10)
       		) );
       		$cmb->add_field( array(
       				'name'          => __( '<h1>Enter the profile info fields below</h1>', 'cmb2' ),
                       'description'   => __( '', 'cmb2' ),                
                       'id'            => $prefix . 'cost_title',
                       'type'          => 'title',
       		) );
       		$cmb->add_field( array(
       				'name'         => __( 'Profile Image', 'cmb2' ),
       				'desc'         => __( 'Upload a profile image this product.', 'cmb2' ),
       				'id'           => $prefix . 'profile_image',
       				'type'         => 'file',
       				'preview_size' => array( 100, 100 ), // Default: array( 50, 50 )
                       'column'        => array('position' => 7)
       		) );
       		$cmb->add_field( array(
       				'name'         => __( 'Profile Width', 'cmb2' ),
       				'desc'         => __( 'Enter the width of this profile.', 'cmb2' ),
       				'id'           => $prefix . 'profile_width',
       				'type'         => 'text',
                       'column'        => array('position' => 8)
       		) );
       		$cmb->add_field( array(
       				'name'         => __( 'Profile Thickness', 'cmb2' ),
       				'desc'         => __( 'Enter the thickness of this profile.', 'cmb2' ),
       				'id'           => $prefix . 'profile_thick',
       				'type'         => 'text',
                       'column'        => array('position' => 9)
       		) );
   
   
   
   
               // REPEATABLE FIELDS FOR COST PER BOX SECTION
       		$group_field_id   = $cmb->add_field( array(
       		'id'              => $prefix . 'box_cost_repeat_group',
       		'type'            => 'group',
       		'object_types'    => array( 'post', 'product' ), // Post type	
       		'description'     => __( '<h1>Enter the cost per box breakdowns in the fields below</h1>', 'cmb2' ),
       		'repeatable'      => true, // use false if you want non-repeatable group
       		'options'         => array(
       				'group_title'       => __( 'Cost Per Box Breakdown {#}', 'cmb2' ), // {#} gets replaced by row number
       				'add_button'        => __( 'Add Another Breakdown Option', 'cmb2' ),
       				'remove_button'     => __( 'Remove Breakown', 'cmb2' ),
       				//'sortable'        => true, // beta
                             ),
                       ) );
                       // Id's for group's fields only need to be unique for the group. Prefix is not needed.
                       $cmb->add_group_field( $group_field_id, array(
                           'name'          => __( '# of Boxes', 'cmb2' ),
                           'id'            => $prefix . 'box_count',
                           'type'          => 'text_small',
                       ) );
                       $cmb->add_group_field( $group_field_id, array(
                           'name'          => __( '$ per Box', 'cmb2' ),
                           'description'   => '',
                           'id'            => $prefix . 'box_cost',
                           'type'          => 'text',
                       ) );
   
   
       /* -----------------------------------------------------------------------------*/
       /*                                                                              */
       /*  Initiate DISTRIBUTORS the metabox    */
       /*                                                                              */
       /* -----------------------------------------------------------------------------*/
       $cmb = new_cmb2_box( array(
       	'id'            => 'distributors_metabox',
       	'title'         => __( 'Distributors', 'cmb2' ),
       	'object_types'  => array( 'post', 'distributors' ), // Post type
       	'context'       => 'normal',
       	'priority'      => 'high',
       	'show_names'    => true, // Show field names on the left
       	'cmb_styles' 	=> true, // false to disable the CMB stylesheet
       	// 'closed'     => true, // Keep the metabox closed by default
       ) );
       		// Distributors & Location(s)
       		// Fields array works the same, except id's only need to be unique for this group. Prefix is not needed.
       		$cmb->add_field ( array(
       						'name' => __( 'Address', 'cmb2' ),
       						'id'   => $prefix . 'distributor_address',
       						'type' => 'text',
       						'column' => array( 'position' => 2, 'name' => 'Address' ),
       						// 'repeatable' => true, // Repeatable fields are supported w/in repeatable groups (for most types)
       					) );
       		$cmb->add_field ( array(
       						'name' => __( 'City', 'cmb2' ),
       						'description' => '',
       						'id'   => $prefix . 'distributor_city',
       						'type' => 'text',
       						'column' => array( 'position' => 3 ),
       					) );
       		$cmb->add_field ( array(
       						'name'    => 'State',
       						'desc'    => 'Select a State',
       						'id'      => $prefix . 'state_select',
       						'type'    => 'select',
       						'column' => array( 'position' => 4 ),
       						'default' => 'custom',
       						'options' => array(
       							'AL'    => __( 'Alabama', 'cmb2' ),
       							'AK'    => __( 'Alaska', 'cmb2' ),
       							'AZ'    => __( 'Arizona', 'cmb2' ),
       							'AR'    => __( 'Arkansas', 'cmb2' ),
       							'CA'    => __( 'California', 'cmb2' ),
       							'CO'    => __( 'Colorado', 'cmb2' ),
       							'CT'    => __( 'Connecticut', 'cmb2' ),
       							'DE'    => __( 'Delaware', 'cmb2' ),
       							'DC'    => __( 'District of Columbia', 'cmb2' ),
       							'FL'    => __( 'Florida', 'cmb2' ),
       							'GA'    => __( 'Georgia', 'cmb2' ),
       							'HI'    => __( 'Hawaii', 'cmb2' ),
       							'ID'    => __( 'Idaho', 'cmb2' ),
       							'IL'    => __( 'Illinois', 'cmb2' ),
       							'IN'    => __( 'Indiana', 'cmb2' ),
       							'IA'    => __( 'Iowa', 'cmb2' ),
       							'KS'    => __( 'Kansas', 'cmb2' ),
       							'KY'    => __( 'Kentucky', 'cmb2' ),
       							'LA'    => __( 'Louisiana', 'cmb2' ),
       							'ME'    => __( 'Maine', 'cmb2' ),
       							'MD'    => __( 'Maryland', 'cmb2' ),
       							'MA'    => __( 'Massachusetts', 'cmb2' ),
       							'MI'    => __( 'Michigan', 'cmb2' ),
       							'MN'    => __( 'Minnesota', 'cmb2' ),
       							'MS'    => __( 'Mississippi', 'cmb2' ),
       							'MO'    => __( 'Missouri', 'cmb2' ),
       							'MT'    => __( 'Montana', 'cmb2' ),
       							'NE'    => __( 'Nebraska', 'cmb2' ),
       							'NV'    => __( 'Nevada', 'cmb2' ),
       							'NH'    => __( 'New Hampshire', 'cmb2' ),
       							'NJ'    => __( 'New Jersey', 'cmb2' ),
       							'NM'    => __( 'New Mexico', 'cmb2' ),
       							'NY'    => __( 'New York', 'cmb2' ),
       							'NC'    => __( 'North Carolina', 'cmb2' ),
       							'ND'    => __( 'North Dakota', 'cmb2' ),
       							'OH'    => __( 'Ohio', 'cmb2' ),
       							'OK'    => __( 'Oklahoma', 'cmb2' ),
       							'OR'    => __( 'Oregon', 'cmb2' ),
       							'PA'    => __( 'Pennsylvania', 'cmb2' ),
       							'RI'    => __( 'Rhode Island', 'cmb2' ),
       							'SC'    => __( 'South Carolina', 'cmb2' ),
       							'SD'    => __( 'South Dakota', 'cmb2' ),
       							'TN'    => __( 'Tennessee', 'cmb2' ),
       							'TX'    => __( 'Texas', 'cmb2' ),
       							'UT'    => __( 'Utah', 'cmb2' ),
       							'VT'    => __( 'Vermont', 'cmb2' ),
       							'VA'    => __( 'Virginia', 'cmb2' ),
       							'WA'    => __( 'Washington', 'cmb2' ),
       							'WV'    => __( 'West Virginia', 'cmb2' ),
       							'WI'    => __( 'Wisconsin', 'cmb2' ),
       							'WY'    => __( 'Wyoming', 'cmb2' ),
       						),
       					)
       					);
       		$cmb->add_field ( array(
       						'name' => __( 'Zip Code', 'cmb2' ),
       						'description' => '',
       						'id'   => $prefix . 'distributor_zip',
       						'type' => 'text',
       						'column' => array( 'position' => 5 ),
       					) );
       		$cmb->add_field ( array(
       						'name' => __( 'Phone', 'cmb2' ),
       						'description' => '',
       						'id'   => $prefix . 'distributor_phone',
       						'type' => 'text',
       						'column' => array( 'position' => 6 ),
       						//'repeatable' => true,
       					) );
       		$cmb->add_field ( array(
       						'name' => __( 'Fax', 'cmb2' ),
       						'description' => '',
       						'id'   => $prefix . 'distributor_fax',
       						'type' => 'text',
       					) );
               $cmb->add_field( array(
                               'name' => __( 'Website', 'cmb2' ),
                               'id'   => 'website',
                               'type' => 'text_url',
                               // 'protocols' => array( 'http', 'https', 'ftp', 'ftps', 'mailto', 'news', 'irc', 'gopher', 'nntp', 'feed', 'telnet' ), // Array of allowed protocols
                           ) );
               $cmb->add_field( array(
                               'name' => __( 'Email Address', 'cmb2' ),
                               'id'   => 'dist_email',
                               'type' => 'text_email',
                               // 'protocols' => array( 'http', 'https', 'ftp', 'ftps', 'mailto', 'news', 'irc', 'gopher', 'nntp', 'feed', 'telnet' ), // Array of allowed protocols
                           ) );
   
   
   
       /* -----------------------------------------------------------------------------*/
       /*                                                                              */
       /*  Initiate STAFF the metabox    */
       /*                                                                              */
       /* -----------------------------------------------------------------------------*/
       $cmb = new_cmb2_box( array(
       	'id'            => 'staff_metabox',
       	'title'         => __( 'Staff', 'cmb2' ),
       	'object_types'  => array( 'post', 'staff' ), // Post type
       	'context'       => 'normal',
       	'priority'      => 'high',
       	'show_names'    => true, // Show field names on the left
       	'cmb_styles' 	=> true, // false to disable the CMB stylesheet
       	// 'closed'     => true, // Keep the metabox closed by default
       ) );
       		// Fields array works the same, except id's only need to be unique for this group. Prefix is not needed.
       		$cmb->add_field ( array(
       						'name'        => __( 'Title', 'cmb2' ),
       						'id'          => $prefix . 'staff_title',
       						'type'        => 'text',
       						'column'      => array( 'position' => 2, 'name' => 'Title' ),
       						// 'repeatable' => true, // Repeatable fields are supported w/in repeatable groups (for most types)
       					) );
       		$cmb->add_field ( array(
       						'name'        => __( 'Office Phone', 'cmb2' ),
       						'description' => '',
       						'id'          => $prefix . 'staff_phone',
       						'type'        => 'text',
       						'column'      => array( 'position' => 6 ),
       						//'repeatable' => true,
       					) );
       		$cmb->add_field ( array(
       						'name'            => __( 'Staff Cell', 'cmb2' ),
       						'description'     => '',
       						'id'             => $prefix . 'staff_cell',
       						'type'           => 'text',
       					) );
               $cmb->add_field( array(
                               'name'          => __( 'Email Address', 'cmb2' ),
                               'id'            => 'staff_email',
                               'type'          => 'text_email',
                               // 'protocols' => array( 'http', 'https', 'ftp', 'ftps', 'mailto', 'news', 'irc', 'gopher', 'nntp', 'feed', 'telnet' ), // Array of allowed protocols
                           ) );
               $cmb->add_field( array(
                               'name'          => __( 'Email Address', 'cmb2' ),
                               'id'            => 'staff_email',
                               'type'          => 'text_email',
                               // 'protocols' => array( 'http', 'https', 'ftp', 'ftps', 'mailto', 'news', 'irc', 'gopher', 'nntp', 'feed', 'telnet' ), // Array of allowed protocols
                           ) );
               $cmb->add_field( array(
                               'name'         => __( 'Staff Pic', 'cmb2' ),
                               'desc'         => __( 'Upload a pic of this staff member if available. If nothing is selected, the default image will be used.', 'cmb2' ),
                               'id'           => $prefix . 'staff_image',
                               'type'         => 'file',
                               'preview_size' => 'small',
                           ) );	   
   
   
       /* -----------------------------------------------------------------------------*/
       /*                                                                              */
       /*  Initiate SALES REPS the metabox    */
       /*                                                                              */
       /* -----------------------------------------------------------------------------*/
       $cmb = new_cmb2_box( array(
       	'id'            => 'reps_metabox',
       	'title'         => __( 'Sales Reps', 'cmb2' ),
       	'object_types'  => array( 'post', 'reps' ), // Post type
       	'context'       => 'normal',
       	'priority'      => 'high',
       	'show_names'    => true, // Show field names on the left
       	'cmb_styles' 	=> true, // false to disable the CMB stylesheet
       	// 'closed'     => true, // Keep the metabox closed by default
       ) );
       		// Fields array works the same, except id's only need to be unique for this group. Prefix is not needed.
       		$cmb->add_field ( array(
       						'name'            => __( 'Phone', 'cmb2' ),
       						'description'     => '',
       						'id'              => $prefix . 'reps_phone',
       						'type'            => 'text',
       						'column'          => array( 'position' => 6 ),
       						//'repeatable' => true,
       					) );
       		$cmb->add_field ( array(
       						'name'            => __( 'Cell', 'cmb2' ),
                               'description'     => '',
       						'id'              => $prefix . 'reps_cell',
       						'type'            => 'text',
       					) );
       		$cmb->add_field ( array(
       						'name'            => __( 'Fax', 'cmb2' ),
                               'description'     => '',
       						'id'              => $prefix . 'reps_fax',
       						'type'            => 'text',
       					) );    
               $cmb->add_field( array(
                               'name'          => __( 'Email Address', 'cmb2' ),
                               'id'            => 'reps_email',
                               'type'          => 'text_email',
                               // 'protocols' => array( 'http', 'https', 'ftp', 'ftps', 'mailto', 'news', 'irc', 'gopher', 'nntp', 'feed', 'telnet' ), // Array of allowed protocols
                           ) );
               $cmb->add_field( array(
                               'name'         => __( 'Reps Pic', 'cmb2' ),
                               'desc'         => __( 'Upload a pic of this sales rep if available. If nothing is selected, the default image will be used.', 'cmb2' ),
                               'id'           => $prefix . 'reps_image',
                               'type'         => 'file',
                               'preview_size' => array( 80, 80 ), // Default: array( 50, 50 )
                               'column'        => array('position' => 9)
                           ) );
   
           // Add other metaboxes as needed
       }
   
   
   
       /* -----------------------------------------------------------------------------*/
       /*                                                                              */
       /*  Initiate TAXONOMY IMAGES the metabox    */
       /*                                                                              */
       /* -----------------------------------------------------------------------------*/
       add_action( 'cmb2_init', 'cmb2_register_taxonomy_metabox' );
       /* Hook in and add a metabox to add fields to taxonomy terms */
       function cmb2_register_taxonomy_metabox() {
       	$prefix = '_cmb2_term_';
   
       /* Metabox to add fields to categories and tags */
       $cmb_term = new_cmb2_box( array(
       	'id'               => $prefix . 'edit',
       	'title'            => esc_html__( 'Department Image', 'cmb2' ),    // Doesn't output for term boxes
       	'object_types'     => array( 'term' ),                             // Tells CMB2 to use term_meta vs post_meta
       	'taxonomies'       => array( 'department', 'post_tag' ),           // Tells CMB2 which taxonomies should have these fields
       	'new_term_section' => true,                                        // Will display in the "Add New Category" section
       ) );
       		$cmb_term->add_field( array(
       			'name' 			=> esc_html__( 'Department Image', 'cmb2' ),
       			'desc' 			=> esc_html__( 'Add an image to represent this department', 'cmb2' ),
       			'id'   			=> $prefix . 'dept_img',
       			'type' 			=> 'file',
       			'column' 		=> array( 'position' => 8 ),
       		) );
       	// Add other metaboxes as needed
       }
       ```
   
 *  Plugin Contributor [Michael Beckwith](https://wordpress.org/support/users/tw2113/)
 * (@tw2113)
 * The BenchPresser
 * [5 years, 8 months ago](https://wordpress.org/support/topic/admin-array-and-header-error/#post-13439332)
 * Hmmm
 * Biggest thing standing out to me is this spot:
 *     ```
       // REPEATABLE FIELDS FOR COST PER BOX SECTION
       $group_field_id   = $cmb->add_field( array(
       	'id'              => $prefix . 'box_cost_repeat_group',
       	'type'            => 'group',
       	'object_types'    => array( 'post', 'product' ), // Post type	
       	'description'     => __( '<h1>Enter the cost per box breakdowns in the fields below</h1>', 'cmb2' ),
       	'repeatable'      => true, // use false if you want non-repeatable group
       	'options'         => array(
       		'group_title'       => __( 'Cost Per Box Breakdown {#}', 'cmb2' ), // {#} gets replaced by row number
       		'add_button'        => __( 'Add Another Breakdown Option', 'cmb2' ),
       		'remove_button'     => __( 'Remove Breakown', 'cmb2' ),
       		//'sortable'        => true, // beta
              ),
       ) );
       ```
   
 * Specifically because you’re providing an object_types parameter for a field that
   doesn’t take them. I’m wondering if that’s somehow throwing things off here.
 * Beyond that, I’m agreeing that all the rest of those object_type spots are passing
   arrays like expected with none nested in like we saw previously.
 *  Thread Starter [EliWbbr](https://wordpress.org/support/users/eliwbbr/)
 * (@eliwbbr)
 * [5 years, 8 months ago](https://wordpress.org/support/topic/admin-array-and-header-error/#post-13439574)
 * “Specifically because you’re providing an object_types parameter for a field 
   that doesn’t take them.”
 * I’m not entirely sure I understand you here. Can you explain that to me like 
   I’m a 5 year old? I won’t be offended!!
 * Thank you again!
 *  Plugin Contributor [Michael Beckwith](https://wordpress.org/support/users/tw2113/)
 * (@tw2113)
 * The BenchPresser
 * [5 years, 8 months ago](https://wordpress.org/support/topic/admin-array-and-header-error/#post-13439610)
 * Make this:
 *     ```
       $group_field_id   = $cmb->add_field( array(
       	'id'              => $prefix . 'box_cost_repeat_group',
       	'type'            => 'group',
       	'object_types'    => array( 'post', 'product' ), // Post type	
       	'description'     => __( '<h1>Enter the cost per box breakdowns in the fields below</h1>', 'cmb2' ),
       	'repeatable'      => true, // use false if you want non-repeatable group
       	'options'         => array(
       		'group_title'       => __( 'Cost Per Box Breakdown {#}', 'cmb2' ), // {#} gets replaced by row number
       		'add_button'        => __( 'Add Another Breakdown Option', 'cmb2' ),
       		'remove_button'     => __( 'Remove Breakown', 'cmb2' ),
       		//'sortable'        => true, // beta
              ),
       ) );
       ```
   
 * be
 *     ```
       $group_field_id   = $cmb->add_field( array(
       	'id'              => $prefix . 'box_cost_repeat_group',
       	'type'            => 'group',
       	'description'     => __( '<h1>Enter the cost per box breakdowns in the fields below</h1>', 'cmb2' ),
       	'repeatable'      => true, // use false if you want non-repeatable group
       	'options'         => array(
       		'group_title'       => __( 'Cost Per Box Breakdown {#}', 'cmb2' ), // {#} gets replaced by row number
       		'add_button'        => __( 'Add Another Breakdown Option', 'cmb2' ),
       		'remove_button'     => __( 'Remove Breakown', 'cmb2' ),
       		//'sortable'        => true, // beta
              ),
       ) );
       ```
   
 * aka don’t pass object types for this spot.

Viewing 15 replies - 1 through 15 (of 20 total)

1 [2](https://wordpress.org/support/topic/admin-array-and-header-error/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/admin-array-and-header-error/page/2/?output_format=md)

The topic ‘admin array and header error’ 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/)

 * 20 replies
 * 2 participants
 * Last reply from: [Michael Beckwith](https://wordpress.org/support/users/tw2113/)
 * Last activity: [5 years, 8 months ago](https://wordpress.org/support/topic/admin-array-and-header-error/page/2/#post-13444392)
 * Status: resolved