Home › Forums › Add-ons › Repeater Field › close if subfield has no value › Reply To: close if subfield has no value
like this??
<?php
function my_repeater() {
if( have_rows('repeater_field') ):
while ( have_rows('repeater_field') ) : the_row();
<div class="contentblock">
<?php $ankerlink = get_sub_field('_repeater_anker'); ?>
<div style="position: relative;">
<?php if( $ankerlink ): ?>
<div id="<?php echo $ankerlink ?>" class="anchorposition"></div>
</div>
<?php endif; ?>
<h3>
<?php the_sub_field('_repeater_headline'); ?>
</h3>
<div class ="repeaterimages">
<?php $images = get_sub_field('_repeater_bild');
if( $images ):?>
<?php foreach( $images as $image ): ?>
<div class="imageblock fitimagecontainer">
<img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt']; ?>" /></div>
<?php endforeach; ?>
</div>
<div class="textblock">
<?php the_sub_field('_repeater_text'); ?>
</div>
</div>
<?php endif;
endwhile;
else :
// no rows found
endif;}
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.