Hello.
I’m having a div containing a h3
-headline and a repeater that inputs values into li
‘s:
<div class="publications">
<h3>Publications</h3>
<ul>
<?php if( have_rows('subpage_publications') ):
while ( have_rows('subpage_publications') ) : the_row(); ?>
<li>
<a href="<?php the_sub_field('document'); ?>">
<?php the_sub_field('document_name'); ?>
</a>
</li>
<?php endwhile; ?>
<?php endif; ?>
</ul>
</div>
Is there any way to hide the entire div
if the fields are empty? Because if the fields are empty now, the headline still prints and I don’t want that.
Thanks in advance
try it like this
<?php if( have_rows('subpage_publications') ): ?>
<div class="publications">
<h3>Publications</h3>
<ul>
<?php while ( have_rows('subpage_publications') ) : the_row(); ?>
<li>
<a href="<?php the_sub_field('document'); ?>">
<?php the_sub_field('document_name'); ?>
</a>
</li>
<?php endwhile; ?>
</ul>
</div>
<?php endif; ?>
That did it! Thanks a lot