I have posts with ACF repeater date fields showing the beginning of an event.
Advanced custom fields has a feature which allows posts to have repeater fields added it it. So I added a repeater date field, so one post can have multiple dates associated with it.
Now I want to list events by the date. I figured out, how to list them by the first date, but how would I go on about listing all of the posts in one list?
Here is the code I have until now (I'm a noob at php):
<?php $posts = get_posts(array(
'numberposts' => -1,
'category' => array('8,11,12'),
'orderby_field' => 'trip_dates_0_start', // order of posts by this field
'orderby_type' => 'date',
'order' => 'ASC' ));
if($posts)
{ foreach($posts as $post) : ?>
<?php while(the_repeater_field('trip_dates')): ?>
<?php the_sub_field('start'); ?>
-
<?php the_sub_field('finish'); ?>
<?php endwhile; ?>
<?php the_title(); ?>
<?php endforeach; } ?>
Now one post would repeat the date field, but be sorted by the first one of them. How do I repeat the post and each have one date? Even if you can't help me with the code, I'd like to know the logic behind creating something like this.