Support

Account

Home Forums Add-ons Repeater Field Display Specific Repeater Field Row Based on Date Reply To: Display Specific Repeater Field Row Based on Date

  • Thanks @james you rock! That worked great. For anyone interested, I’m posting my complete code below.

    
    <?php if( have_rows('contact_hours', 25) ): ?>
        <div class="footer-hours">
    	    <div class="footer-hours-title">Hours</div>
    	    <?php while ( have_rows('contact_hours', 25) ) : the_row(); ?>
    	        <?php
    	        $begin_date = DateTime::createFromFormat('m', get_sub_field('date_range_beginning'));
    			$end_date = DateTime::createFromFormat('m', get_sub_field('date_range_ending'));
    	        $current_date = (int) date('m');
    			$start = (int) get_sub_field('date_range_beginning');
    			$end = (int) get_sub_field('date_range_ending');
    			if ($current_date >= $start && $current_date <= $end) { ?>
    		        <div class="footer-hour-segment">
    			        <div class="contact-range">
    					    <div class="contact-date-range"><?php echo $begin_date->format('F'); ?> - <?php echo $end_date->format('F'); ?></div>
    					    <div class="contact-hour-days"><?php the_sub_field('contact_hour_days', 25); ?></div>
    				        <div class="contact-hour-hours"><?php the_sub_field('contact_hour_hours', 25); ?></div>
    			        </div>
    		        </div>
    	        <?php } ?>
    	    <?php endwhile; ?>
        </div><!--footer-hours-->
    <?php endif; ?>