Home Forums Front-end Issues Sort events by date Reply To: Sort events by date

  • Hi @alexnl88

    Hmm… May be you could have an array that records the date field’s values then use in_array() PHP function to check if the array contains some the date value if not, then add it. The code would look something like this:

    $dates = array();
    if (have_posts()) : while(have_posts()) : the_post();
      $acf_date = the_field('event_date');
      if ( !in_array($acf_date, $dates) ){ ?>
    <div><?php echo $acf_date; array_push($dates, $acf_date); ?><?div>
    <?php } endwhile; endif; ?>

    For more information, check out the following links: