After updating to 5.11 the output from a cloned repeater get_field changed to:
Array
(
[field_5eb009ab7326d_field_593a81a41c9f6] =>
)
So cannot loop with for each anymore. using the_row with get_sub_field works as expected though and I can see the data when looping this way.
Any ideas why this would return as above with get_field?
Can you supply a portion the code that was working and now isn’t?
Sure, have condensed:
$disclaimers = get_field(‘disclaimers’);
if( !empty($disclaimers) ) {
foreach( $disclaimers as $disclaimer ) {
$disclaim_type = $disclaimer['disclaimer'];
#then looping through to generate a string
}
}
This get_field gives an empty array as above in first post. So the foreach loop fails.
If I do like this I can see the data as expected:
if( have_rows('disclaimers') ) {
while( have_rows('disclaimers') ) {
the_row();
// vars
$disclaimer = get_sub_field('disclaimer');
print_r($disclaimer);
}
}
I rolled back to version 5.10.2 and the first foreach snippet worked again.
I have a site that uses clone fields in exactly the same way that I just updated and everything is working as expected.
I need to know more information about your code. Is this called in the template file? is it in a plugin files? When is it called? Is it possible that this is called before the acf/init action has fired?
Thanks for asking the right questions. I looked deeper and was trying get_field first and then if that returned nothing trying get_sub_field. This output must have been updated within the update so have updated it to account for this.
Thanks for your help!