Hi, for years no issue with ACF/repeaters, but now get_field(‘repeater_name’) is not returning an array but instead the number of the rows saved in the DB. The DB looks fine and I could loop through the fields with the ‘repater_name_’.$i.’_sub_field_name’ method but I like to solve this. Note: Although there are many entries, the while(has_sub_field(‘repater_name’)) is only looping once. Glad for any advice!
Solved: it was a key issue, didn’t use the “field_XXXXXXX” format in the register_field_group array; Do it!
This can also happen if you call get_field too early, I had a case where I called it at the top of the functions.php file in a $_GET check and it wouldn’t load the data for a repeater field, just the number of elements.
For Example:
if( $_GET['dostuff'] == 'yes'){
$data = get_field('fieldname', 'option');
//do stuff
//$data returned "3"
}
I solved this by moving it to a function in an init action
if( $_GET['dostuff'] == 'yes'){
add_action('init', 'functionname');
}
function functionname(){
$data = get_field('fieldname', 'option');
//do stuff
//$data returned array
}