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++;
}
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
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 Privacy Policy. If you continue to use this site, you consent to our use of cookies.