ACF Pro Gallery Field. get_field not working

  acfpro, advanced-custom-fields, flickity, php, wordpress

Super rookie with PHP.

I’m trying to create a slideshow using ACF Pro and Flickity.

My code seems to be detecting image fields, but the <img> source is not displaying anything.

Maybe the get_field('gallery'); is not correct.

Here’s my code. Any thoughts would be super helpful 🙂

<div class="main-carousel">
        <?php $images = get_field('gallery'); ?>
        <?php if ( $images ): ?>

            <?php foreach( $images as $image ): ?>
                <div class="carousel-cell">
                        <img src="<?php echo $image['sizes']['large '];?> ">
                </div>
            <?php endforeach; ?>
            
            <?php elseif ( !$images): ?> 
                <p>nothing to show</p>
                
        <?php endif; ?>

Source: Ask PHP

LEAVE A COMMENT