I have a page on my site that lists past events by year and then within each year lists the event by month/day. I can get the code to display by year but then the month is not in chronological order OR I can get the code to display by year and chronological order but then it displays events from two categories.
I'm looking to get events in one category (Indoor Track and Field) to display by year, and then within each year by date. Can anyone point me in the right directions? I've posted the code below. I'm using ACF and WordPress if that makes a difference. This code is showing both categories by year / month.
Thanks in advance!
$date2018 = date( '2018-12-31' );
$posts2018 = get_posts(array(
'posts_per_page' => -1,
'post_type' => 'events',
'meta_key' => 'event_category',
'meta_value'=> 'Indoor Track and Field',
//'orderby' => 'meta_value_num',
//'order' => 'ASC',
'meta_query'=> array(
'meta_key' => 'event_date',
'orderby' => 'meta_value_num',
'order' => 'ASC',
'relation' => 'AND',
array(
'key' => 'event_date',
'compare' => '<=',
'value' => $date2018,
'type' => 'DATE',
),
array(
'key' => 'event_date',
'compare' => '>=',
'value' => date( "2018-01-01" ),
'type' => 'DATE',
)
)
));