Home Forums Add-ons Flexible Content Field Image not dispalying front end.


Image not dispalying front end.

  • 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?


    $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? :

    // 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' ):
            elseif( get_row_layout() == 'other_flexible_content_layout_name' ): 
            	$field = get_sub_field('other_field');
            	echo $field;
    else :
        // no layouts found
Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘Image not dispalying front end.’ is closed to new replies.