I am not able to display an image field that is a flexible content sub field.
This what I am using. How would I call up the image that is in the flexible content sub field?
<?php
$image = get_field(‘calculator_image_1’);
if( !empty($image) ): ?>
” alt=”<?php echo $image[‘alt’]; ?>” />
<?php endif; ?>
The flexible content field name is “calculator_page”
The image sub field name is “calculator_image_1”
please wrap your code inside code tags (button at top of textfield, where you write forum post)
and show the whole loop (at least the if get_row_layout part. of course you can/should reduce fields/layouts to dont get to long code. but we need to understand what you did wrong)
did your code look somehow like this? :
<?php
// check if the flexible content field has rows of data
if( have_rows('flexible_content_field_name') ):
// loop through the rows of data
while ( have_rows('flexible_content_field_name') ) : the_row();
if( get_row_layout() == 'flexible_content_layout_name' ):
the_sub_field('some_field');
elseif( get_row_layout() == 'other_flexible_content_layout_name' ):
$field = get_sub_field('other_field');
echo $field;
endif;
endwhile;
else :
// no layouts found
endif;
?>