Home Forums ACF PRO Repeater: Hide output if sub_field is empty Reply To: Repeater: Hide output if sub_field is empty

  • I solved this for anyone else that has the same problem. It was basically my ignorance and oversight:

    <section id="awards">
      <?php if( have_rows('award_images', 'options', true) ): ?>
        <div class="container">
          <div class="row">
            <h2 class="awards text-center"><span>Awards</span></h2>
              <div class="awards-wrap col-md-12">
                <ul class="awards">
                    while( have_rows('award_images', 'options', true) ): the_row();
              		  // vars
              		  $award_image = get_sub_field('award_image');
              		  $award_image_link = get_sub_field('award_image_link');
              		<li class="award">
              			<?php if( $award_image_link ): ?>
              				<a href="<?php echo $award_image_link; ?>">
              			<?php endif; ?>
              				<img src="<?php echo $award_image['url']; ?>" alt="<?php echo $award_image['alt'] ?>" />
              			<?php if( $award_image_link ): ?>
              			<?php endif; ?>
              	 <?php endwhile; ?>
         <?php endif; ?>

    I just moved the if (have_rows() ) line inside the section element. 🙂