Home Forums Add-ons Flexible Content Field Trouble Displaying Flexible Content Field Content


Trouble Displaying Flexible Content Field Content

  • So I’m making a Flexible Field where the user can decide to display a certain number of banners at the bottom of the screen. They choose between one and three. Once there, they dump a few images in and they should show up on the front end. Problem is nothing is displaying on the front end. I pasted the code below. I have checked the names a hundred times so I’m positive all the fields are called by their correct names, but if there is more code I can post to help let me know.

      if( have_rows('bottom_banners') ):
       while ( have_rows('bottom_banners') ) : the_row();
        if( get_row_layout() == 'one_banner' ):?>
            <div class="col-md-12"><img src="<?php the_sub_field('banner'); ?>"/></div>
        <?php elseif( get_row_layout() == 'two_banner' ): ?>
            <div class="col-md-6"><img src="<?php the_sub_field('banner_1'); ?>"/></div>
            <div class="col-md-6"><img src="<?php the_sub_field('banner_2'); ?>"/></div>
        <?php elseif( get_row_layout() == 'three_banner' ): ?>
            <div class="col-md-4"><img src="<?php the_sub_field('banner_1'); ?>"/></div>
            <div class="col-md-4"><img src="<?php the_sub_field('banner_2'); ?>"/></div>
            <div class="col-md-4"><img src="<?php the_sub_field('banner_3'); ?>"/></div>
        <?php endif;
            else :
             // no layouts found
  • Hi @epstein,

    I cannot see any problems with your code here. Could you try doing a var_dump(get_sub_row('banner_1'));?

    My feeling is that the images are not being stored correctly.


  • A var_dump doesn’t return anything so I agree it must be the way they are stored. I took a screenshot of the setup of the flexible field. Thanks for the help, I’m at a loss on what to do since I had no issues getting the flexible field to work with a repeater inside.

  • Hi @epstein

    Lets try a few things.
    1. Turn on DEBUG_MODE in your wp-config.php file. This will show any PHP errors
    2. What version of ACF are you using?
    3. Try debugging the value like so:

    $banners = get_field('bottom_banners');
    echo '<pre>';
    	print_r( $banners );
    echo '</pre>';
    die; ?>

    4. Is this code in the footer.php? If so, is the $post correct for ACF to load from the correct post/page?

  • When I went to check my version number I realized that I’m a version behind and the patch notes say you added some of the calls I used in my original code. Updating all my plugins and WordPress solved my problem.

    Always the easy solutions! Thanks for the help!

Viewing 5 posts - 1 through 5 (of 5 total)

The topic ‘Trouble Displaying Flexible Content Field Content’ is closed to new replies.