page.php
while ( have_rows( 'sections' ) ) : the_row(); // sections - Flexible Content
get_template_part( 'blocks/block', get_row_layout() );
endwhile;
blocks/block-hero.php
$image = get_sub_field('image');
return false
Even though images is added
https://screenrec.com/share/8jVvJtCkGd
https://screenrec.com/share/8jVvJtCkGd
And same error in all section(((
Please help!!!
New update
$image = get_sub_field('image');
if( have_rows('slider') ) :
$image = array[…]
if( have_rows('slider') ) :
$image = get_sub_field('image');
$image = false
But before currnet row changed only after the_row(); function.
You have a repeater nested within an ACF flexible content field so where get_sub_field is looking for data is changing based on where you’re placing it.
Ex: when you put it ABOVE the slider repeater, it’s looking for the image field in the flexible content area. When you put it after the loop for your repeater, it’s looking for the image field as a subfield of “slider”. That’s why it’s returning null when you move where it’s located.
If you want to use a field assigned to the flexible content layout inside of the nested repeater, your best bet would be likely to assign it to a variable ahead of opening your slider repeater loop so leave the $image variable where it is in your working example and then reference that variable within your slider repeater loop.