Support

Account

Home Forums Pre-purchase Questions Gallery add-on Reply To: Gallery add-on

  • Thank you and sorry for taking so long to answer.

    Unfortunately it seems like this isn’t working either. It’s not taking the correct images from the gallery field and shows only the featured image of the post. This is the code I used:

    
    <?php
    
    $images = get_field('MYFIELDNAME');
    $image_ids = array();
    $max = 5;
    $i = 0;
    
    if( $images )
    {
    	foreach( $images as $image )
    	{
    		$i++;
    		
    		if( $i > $max){ break; }
    		
    		$ids[] = $image['id'];
    	}
    }
    
    $shortcode = '[gallery columns="1" link="file" size="medium" ids="' . implode(',', $image_ids) . '"]';
    
    echo do_shortcode( $shortcode );
    
    ?>

    Is there something I’m doing wrong? Any other data I should change in addition to the field name after “get_field”?