Cannot clone group of Custom Fields in CPT
I have my CPT, and I am trying to clone the group of Custom Fields in my metabox named as Credits
.
I have these fields to be cloned each time, when the user hit on + Add Group
button:
- Text Field
- TextArea Field
I have followed this link for reference -> Clone Group of Custom Fields
Now, I believe the code is right, but somehow, I can see only textfield
is coming up. I have tried my best to get this working but failed. I need your help on this. Metabox Group extension is a paid extension, and I do not want make use of it
Code:
function gallery_credit_section( $meta_boxes ) {
$prefix = 'prefix-';
$meta_boxes[] = array(
'id' => $prefix . 'gallery-credits',
'title' => esc_html__( 'Credits', 'metabox-online-generator' ),
'post_types' => 'gallery',
'context' => 'advanced',
'priority' => 'default',
'autosave' => 'false',
'fields' => array(
array(
'id' => $prefix . 'gallery-advisor',
'type' => 'group',
'clone' => true,
'fields' => array(
array(
'id' => $prefix . 'gallery-advisor',
'type' => 'text',
'name' => esc_html__( 'Advisors', 'metabox-online-generator' ),
'placeholder' => esc_html('Author Name', 'metabox-online-generator')
),
array(
'id' => $prefix . 'gallery-about-advisor',
'type' => 'textarea',
'name' => esc_html__('About Advisor', 'metabox-online-generator')
)
)
)
)
);
return $meta_boxes;
}
add_filter( 'rwmb_meta_boxes', 'gallery_credit_section' );
Result:
As you can see, no name is there for the field, plus there is no textarea
field too. Please help. Thanks 🙂
Leave an answer