在里面CMB2 您可以使用group
键入以创建重复字段,然后在组内声明text_date
类型
假设你有一个Events 您可以在其中设置多个日期。
$events = new_cmb2_box([
\'id\' => \'events_metabox\',
\'title\' => __(\'Events\', \'text_domain\'),
\'object_types\' => ...,
\'show_on\' => ...,
...
]);
$events_group_id = $events->add_field([
\'id\' => \'events\',
\'type\' => \'group\',
\'desc\' => ...,
\'options\' => [
\'group_title\' => __(\'Event Date {#}\', \'text_domain\'),
\'add_button\' => __(\'New Event Date\', \'text_domain\'),
\'remove_button\' => __(\'Remove Event Date\', \'text_domain\')
]
]);
$events->add_group_field($events_group_id, [
\'id\' => \'event_text_date\',
\'name\' => __(\'Event Date\', \'text_domain\'),
\'desc\' => ...,
\'type\' => \'text_date\'
]);