Hi all,
I’m using the code below to get 2 images created within a flexible content field
I have one flexible content field and 2 layouts within it. Each of these layouts has a field to store an image. Both of these are set to return an image array. In the code below, the first get_sub_field returns an ID, the second one returns an array. I could test for an array to make the code work but I’ve no idea why it’s happening.
Can anyone help?
Thanks, Steve
if( have_rows('home_content') ):
// loop through the rows of data
while ( have_rows('home_content') ) : the_row();
if( get_row_layout() == 'home_welcome_content' ):
$image = get_sub_field('home_join_us_image'); // returns an ID
var_dump($image);
elseif (get_row_layout() == 'home_merchandise_content' ):
$image = get_sub_field('home_merchandise_image'); // returns an array
var_dump($image);
endif;
endwhile;
else :
// no layouts found
endif;