Home › Forums › Add-ons › Repeater Field › FOR EACH Inside of an IF/ELSE using Select Field/Repeater › Reply To: FOR EACH Inside of an IF/ELSE using Select Field/Repeater
Thank you so much! That worked!!! I really appreciate it!
This code has brought up one other question – is it possible to add a conditional within the repeater. Is there a specific syntax to be used?
I have tried multiple ways of writing it with no luck.
<?php
foreach ($section['testimonials'] as $item => $block) :
?>
<div class="testimonial-slideshow__slide background-cover">
<div class="testimonial-slideshow__slide-content">
<?=$block['testimonial_text']?>
<h5>- <?=$block['testimonial_attribution']?></h5>
<?php if ($block['testimonial_image'] !== '') : ?>
<div class="testimonial-image"><img src="<?=$block['testimonial_image']['sizes']['image-90-90']?>"/></div>
<?php endif; ?>
<?php if ($block['button_url'] !== '') : ?>
<a href="<?=$block['button_url']?>" class="caps outline button" ><?=$block['button_text']?></a>
<?php endif; ?>
</div>
</div>
<?php endforeach; ?>
Oddly the button stays hidden but the testimonial_image circle div doesn’t stay hidden.
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.