
I’m trying to modify this to work on a page, but instead of using the options page I have the repeater on the same page that has choice field I want changed. The code below isn’t working when the repeater field (“test_categories”) is nested inside a group field called ‘build_links’:
function acf_load_color_field_choices($field) {
$field['choices'] = array();
if(have_rows('build_links')) {
while(have_rows('build_links')) {
the_row();
if(have_rows('test_categories')) {
while(have_rows('test_categories')) {
the_row();
$value = get_sub_field('category');
$field['choices'][$value] = $value;
}
}
}
}
return $field;
}
add_filter('acf/load_field/key=field_5b2c0cba3f931','acf_load_color_field_choices');
But when I move the repeater “test_categories” outside of the group and change it to this it works?
function acf_load_color_field_choices($field) {
$field['choices'] = array();
if(have_rows('test_categories')) {
while(have_rows('test_categories')) {
the_row();
$value = get_sub_field('category');
$field['choices'][$value] = $value;
}
}
return $field;
}
add_filter('acf/load_field/key=field_5b2c0cba3f931','acf_load_color_field_choices');