如果看起来您正在使用CMB(WordPress的自定义元框和字段)创建您的创建元框。CMB已经为您提供了一个可以使用的分组和重复元框选项。你可以检查这个link
就您的代码而言,假设它应该是这样的:
function dikka_cmb_meoxes( array $meta_boxes ) {
$prefix = \'dikka_\';
$meta_boxes[\'details_meox\'] = array(
\'id\' => $prefix . \'details_meox\',
\'type\' => \'group\',
\'pages\' => array( \'portfolio\', ), // Post type
\'description\' => __( \'Porject Details\', \'dikka\' ),
\'options\' => array(
\'group_title\' => __( \'Entry {#}\', \'dikka\' ), // since version 1.1.4, {#} gets replaced by row number
\'add_button\' => __( \'Add Another Entry\', \'dikka\' ),
\'remove_button\' => __( \'Remove Entry\', \'dikka\' ),
\'sortable\' => true, // beta
),
// Fields array works the same, except id\'s only need to be unique for this group. Prefix is not needed.
\'fields\' => array(
array(
\'name\' => __( \'Client\', \'dikka\' ),
\'desc\' => __( \'Add client name\', \'dikka\' ),
\'id\' => $prefix . \'add_client\',
\'type\' => \'text\',
),
array(
\'name\' => __( \'Skills\', \'dikka\' ),
\'desc\' => __( \'Add skills\', \'dikka\' ),
\'id\' => $prefix . \'skills\',
\'type\' => \'text\',
),
array(
\'name\' => __( \'Release Date\', \'dikka\' ),
\'desc\' => __( \'Add release date of project\', \'dikka\' ),
\'id\' => $prefix . \'add_releasedate\',
\'type\' => \'text_date\',
),
),
),
return $meta_boxes;
}
希望这有帮助!