Support

Account

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

Solved

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

  • 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

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

  • 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);
    
  • Hi,

    sorry for the late reply.

    This is what I get with (for testing) 1 image:

    Warning: Invalid argument supplied for foreach() in /var/www/html/live/files/plugins/advanced-custom-fields-pro/includes/api/api-helpers.php on line 3213
    array(1) { [0]=> array(24) { ["ID"]=> int(282347) ["id"]=> int(282347) ["title"]=> string(14) "04_Porsche_917" ["filename"]=> string(18) "04_Porsche_917.jpg" ["filesize"]=> int(223682) ["url"]=> string(69) "https://aure3.will-fahren.at/files/uploads/2019/03/04_Porsche_917.jpg" ["link"]=> string(75) "https://aure3.will-fahren.at/autowelt/porsche-917/attachment/04_porsche_917" ["alt"]=> string(0) "" ["author"]=> string(4) "1838" ["description"]=> string(0) "" ["caption"]=> string(183) "Der 917-001 wurde als erstes von insgesamt 25 Exemplaren der Homologationsserie im Frühjahr 1969 aufgebaut und als Gruppe-4-Sportwagen vor dem Porsche Werk 1 in Zuffenhausen gezeigt." ["name"]=> string(14) "04_porsche_917" ["status"]=> string(7) "inherit" ["uploaded_to"]=> int(282339) ["date"]=> string(19) "2019-03-12 08:03:18" ["modified"]=> string(19) "2019-03-12 08:04:52" ["menu_order"]=> int(0) ["mime_type"]=> string(10) "image/jpeg" ["type"]=> string(5) "image" ["subtype"]=> string(4) "jpeg" ["icon"]=> string(65) "https://aure3.will-fahren.at/wp-includes/images/media/default.png" ["width"]=> int(1150) ["height"]=> int(647) ["sizes"]=> array(0) { } } }

    I realized that this error message also appears in the Admin Area right above the Custom Fields.

    Thanks and Greetings
    Mikkel

  • Hi,

    sorry for the late reply.

    This is what I get with (for testing) 1 image:

    Warning: Invalid argument supplied for foreach() in /var/www/html/live/files/plugins/advanced-custom-fields-pro/includes/api/api-helpers.php on line 3213

    array(1) { [0]=> array(24) { ["ID"]=> int(282347) ["id"]=> int(282347) ["title"]=> string(14) "04_Porsche_917" ["filename"]=> string(18) "04_Porsche_917.jpg" ["filesize"]=> int(223682) ["url"]=> string(69) "https://aure3.will-fahren.at/files/uploads/2019/03/04_Porsche_917.jpg" ["link"]=> string(75) "https://aure3.will-fahren.at/autowelt/porsche-917/attachment/04_porsche_917" ["alt"]=> string(0) "" ["author"]=> string(4) "1838" ["description"]=> string(0) "" ["caption"]=> string(183) "Der 917-001 wurde als erstes von insgesamt 25 Exemplaren der Homologationsserie im Frühjahr 1969 aufgebaut und als Gruppe-4-Sportwagen vor dem Porsche Werk 1 in Zuffenhausen gezeigt." ["name"]=> string(14) "04_porsche_917" ["status"]=> string(7) "inherit" ["uploaded_to"]=> int(282339) ["date"]=> string(19) "2019-03-12 08:03:18" ["modified"]=> string(19) "2019-03-12 08:04:52" ["menu_order"]=> int(0) ["mime_type"]=> string(10) "image/jpeg" ["type"]=> string(5) "image" ["subtype"]=> string(4) "jpeg" ["icon"]=> string(65) "https://aure3.will-fahren.at/wp-includes/images/media/default.png" ["width"]=> int(1150) ["height"]=> int(647) ["sizes"]=> array(0) { } } }

    I realized that this error message also appears in the Admin Area right above the Custom Fields.

    Thanks and Greetings
    Mikkel

  • I try to put in the Error Message and the Output from var_dump, but it won’t let me…

  • array(1) { [0]=> array(24) { [“ID”]=> int(282347) [“id”]=> int(282347) [“title”]=> string(14) “04_Car_917” [“filename”]=> string(18) “04_Car_917.jpg” [“filesize”]=> int(223682) [“url”]=> string(69) “https://domainname.com/uploads/2019/03/04_Car_917.jpg&#8221; [“link”]=> string(75) “https://domainname.com/attachment/04_Car_917&#8221; [“alt”]=> string(0) “” [“author”]=> string(4) “1838” [“description”]=> string(0) “” [“caption”]=> string(183) “Der 917-001 wurde als erstes von insgesamt 25 Exemplaren gezeigt.” [“name”]=> string(14) “04_porsche_917” [“status”]=> string(7) “inherit” [“uploaded_to”]=> int(282339) [“date”]=> string(19) “2019-03-12 08:03:18” [“modified”]=> string(19) “2019-03-12 08:04:52” [“menu_order”]=> int(0) [“mime_type”]=> string(10) “image/jpeg” [“type”]=> string(5) “image” [“subtype”]=> string(4) “jpeg” [“icon”]=> string(65) “https://domainname.com/wp-includes/images/media/default.png&#8221; [“width”]=> int(1150) [“height”]=> int(647) [“sizes”]=> array(0) { } } }

  • Now it is working

  • Hi,

    I can inform you, that the Error Messages are not caused from your Plugin.

    I did overtake a website. I found in the functions a code, which provided an image gallery with “next / prev” Navigation. So every Image has its own URL.

    define('ARBP_VERSION', '0.2');
    define('ARBP_TYPE', 'ar_big_pictures');
    define('ARBP_IMAGE_TYPE', 'ar_biggallery');
    
    add_action('init', 'register_arbp_type');
    //add_image_size(ARBP_IMAGE_TYPE, 930, 523, true); 
    
    add_filter( 'intermediate_image_sizes', function($sizes){
        if (!isset($_REQUEST['post_id'])) { return; }
        
        $type = get_post_type($_REQUEST['post_id']);
        foreach($sizes as $key => $value){
            /*if(($type == ARBP_TYPE  &&  $value != ARBP_IMAGE_TYPE && $value != 'thumbnail')
               || ($type != ARBP_TYPE && $value == ARBP_IMAGE_TYPE)){*/
    	if ($type != ARBP_TYPE && $value == ARBP_IMAGE_TYPE) {
                unset($sizes[$key]);
            }
        }
        return $sizes;
    });
    
     
    function register_arbp_type() {
    	
    	$labels = array(
    		'name' => 'Diashow',
    		'singular_name' => 'Diashow',
    		'add_new' => 'Neu',
    		'add_new_item' => 'Neue Diashow',
    		'edit_item' => 'Bearbeite Diashow',
    		'new_item' => 'Neue Diashow',
    		'all_items' => 'Alle Diashows',
    		'view_item' => 'Diashow betrachten',
    		'search_items' => 'Suche nach Diashows',
    		'not_found' =>  'Keine Diashows gefunden',
    		'not_found_in_trash' => 'Keine Diashows im Papierkorb gefunde', 
    		'parent_item_colon' => '',
    		'menu_name' => 'Diashows'
    	  );
    
    	$args = array(
    		'labels' => $labels,
    		'public' => true,
    		'publicly_queryable' => true,
    		'show_ui' => true, 
    		'show_in_menu' => true, 
    		'query_var' => true,
    		'rewrite' => array( 'slug' => 'diashow' ),
    		'capability_type' => 'post',
    		'has_archive' => true, 
    		'hierarchical' => false,
    		'menu_position' => null,
    		
    		'taxonomies' => array('category'),
    		
    		'supports' => array( 'title', 'editor', 'author', 'comments', 'excerpt', 'thumbnail' )
    	); 
    	
    	register_post_type(ARBP_TYPE , $args );
    }
    
    if (is_admin() && isset($_GET['post_type']) && $_GET['post_type'] == ARBP_TYPE) {
        add_action( 'wp_print_scripts', 'ar_big_picts_de_script', 110 );
    }
    
    function ar_big_picts_de_script() {
        wp_dequeue_script('wp-category-permalink.js');
        wp_deregister_script('wp-category-permalink.js');
    }

    When I delete this Code, the Error Messages disappear.

    Just because I’m corious – do you see where the Problem is?

    Thanks a lot for your Help!

    Best
    Mikkel

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

The topic ‘Warning: Invalid argument "**" foreach "**" api-helpers.php on line 3213’ is closed to new replies.