Custom Fields
Re-Envisioned
Support General Multiple Metabox array names Reply To: Multiple Metabox array names

#12354

Anh Tran
Keymaster

Hi Nakaiya,

Yes, of course. But in the callback function of the rwmb_meta_boxes filter, please just use the variable $meta_boxes. It’s an array of meta boxes. Each meta box has a different title.

So, your code can be modified to this:

add_filter( 'rwmb_meta_boxes', 'announcements_register_meta_boxes' );
function announcements_register_meta_boxes( $meta_boxes ) {
    $prefix = 'announcements_';
    $meta_boxes[] = array(
        'id'         => 'announcements',
        'title'      => 'Announcements Meta',
        'post_types' => 'announcements',

        'fields' => array(
            // DATE
            array(
                'name'       => __( 'Event Date - If nothing is entered here, the post publish date will be used', 'announcements_' ),
                'id'         => "{$prefix}display_date",
                'type'       => 'date',
            ),

        )
    );
    return $meta_boxes;
}

add_filter( 'rwmb_meta_boxes', 'register_meta_boxes' );
function register_meta_boxes( $meta_boxes ) {
    $prefix = 'uu_';
    $meta_boxes[] = array(
        'id'         => 'uu_metabox',
        'title'      => 'My Metabox',
        'post_types' => 'post',

        'fields' => array(
            // DATE
            array(
                'name'       => __( 'Event Date - If nothing is entered here, the post publish date will be used', 'announcements_' ),
                'id'         => "{$prefix}display_date",
                'type'       => 'date',
            ),

        )
    );
    return $meta_boxes;
}