Support

Account

Home Forums General Issues acf conditional logic with more than one image field Reply To: acf conditional logic with more than one image field

  • What are the names of your fields? What are the return values of your fields?

    This is just a general idea because I don’t have the details.

    
    <?php 
    // get all for fields and add them to an array
    $images = array();
    $images[] = get_field('image_field_1');
    $images[] = get_field('image_field_2');
    $images[] = get_field('image_field_3');
    $images[] = get_field('image_field_4');
    
    $current_image = 0;
    foreach ($images as $image) {
      $class = 'col-12';
      if (($current_image == 0 || $current_image == 2) && isset($images[$current_images+1])) {
        $class 'col-6';
      }
      ?><div class="<?php echo $class; ?>">image here</div><?php 
      $current_image++;
    }