Support

Account

Home Forums ACF PRO Warning: Invalid argument "**" foreach "**" api-helpers.php on line 3213

Solving

Warning: Invalid argument "**" foreach "**" api-helpers.php on line 3213

    • a2c

    • July 21, 2020 at 8:02 pm

    Hi,

    I only get this on an article page where I have a repeater to fill a “Flickity Slider”.

    My Code is:

    <div class="ar-karussell-wrapper">
    <div class="ar-karussell">
    
    	<?php foreach( $images as $image ): ?>
    	<div class="carousel-cell">
    	<figure class="article-feat-figure">
    	<img data-flickity-lazyload-src="<?php echo $image['url']; ?>" alt="<?php echo $image['caption']; ?>">
    	</figure>
    <?php 
    								if($image['caption']!="" ){
    ?>
    <div class="img-caption-featured"><?php echo $image['caption']; ?></div>
    			<?php }
    				else{ ?>
    			<?php } ?>
    		</div>
    	<?php endforeach; ?>
    					
    </div>
    </div>

    Does anybody see what’s wrong with it? It is working… but with “Show Error” I see these Warnings.

    Thanks for Help in Advance
    Greeting Mikkel

    • a2c

    • July 21, 2020 at 8:16 pm

    Sorry, can´t edit my original post. It is not a repeater – it is a Gallery Field…

  • What is $images? where is it set?

    I’m assuming you have something like

    
    $images = get_field('gallery_field');
    

    please supply the code entire code for this field

    Where is the gallery field, on a post? a term?

    • a2c

    • July 21, 2020 at 9:31 pm

    Hello John,

    yes you are right – I forgot to put in another line of code:

    <?php $images = get_field('bildergalerie'); if( $images ): ?>
        <div class="ar-karussell-wrapper">
        <div class="ar-karussell">
    
            <?php foreach( $images as $image ): ?>
                
                <div class="carousel-cell">
                    <figure class="article-feat-figure">
                    <img data-flickity-lazyload-src="<?php echo $image['url']; ?>" alt="<?php echo $image['caption']; ?>">
                    </figure>
    
                <?php 
                  if($image['caption']!="" ){
                ?>
    
                <div class="img-caption-featured"><?php echo $image['caption']; ?></div>
                    <?php }
                        else{ ?>
                    <?php } ?>
                </div>
            <?php endforeach; ?>
    					
        </div>
        </div>
    <?php endif; ?>

    The Gallery is on a post.

    Thanks for your reply!
    Best Mikkel

  • I would start by seeing what is being returned by get_field

    
    $images = get_field('bildergalerie');
    var_dump($images);
    
Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.