if( function_exists('acf_add_local_field_group') ):
acf_add_local_field_group(array(
'key' => 'group_1',
'title' => 'My Repeater',
'fields' => array(
array(
'key' => 'field_1',
'label' => 'Title',
'name' => 'title',
'type' => 'text'
),
array(
'key' => 'field_2',
'label' => 'Repeater',
'name' => 'repeater',
'type' => 'repeater',
'sub_fields' => array(
array(
'key' => 'sub_field_1',
'label' => 'Sub Field 1',
'name' => 'sub_field_1',
'type' => 'text'
),
array(
'key' => 'sub_field_2',
'label' => 'Sub Field 2',
'name' => 'sub_field_2',
'type' => 'text'
)
)
)
),
'location' => array(
array(
array(
'param' => 'post_type',
'operator' => '==',
'value' => 'post'
)
)
)
));
endif;
if( have_rows('repeater') ):
while ( have_rows('repeater') ) : the_row();
//display sub field values
echo get_sub_field('sub_field_1');
echo get_sub_field('sub_field_2');
endwhile;
endif;
注:以上示例代码仅供参考。请按照您的需要自行修改。