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?
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
elseif (get_row_layout() == 'home_merchandise_content' ):
$image = get_sub_field('home_merchandise_image'); // returns an array
// no layouts found
Viewing 1 post (of 1 total)
You must be logged in to reply to this topic.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users