Sort custom post type by custom datepicker instead of filtering
I have a custom post type Event that I use in conjunction with ACF. I have a group called event and inside that group I have a field called date_start. And this is the code that I currently have, but it filters instead of sorts, meaning every past event is not visible.
$args = array(
'post_type' => 'events',
'posts_per_page' => '-1',
'meta_query' => array(
array(
'key' => 'event_date_start' ,
'compare' => '>=',
'value' => current_time('Ymd'),
)
),
'meta_key' => 'event_date_start',
'orderby' => 'meta_value_num',
'order' => 'ASC'
);
Also, I have tried this code to no avail from a similar question here.
$args = array(
'post_type' => 'events',
'posts_per_page' => '-1',
'orderby' => 'meta_value_num ',
'meta_key' => 'event_date_start',
'order' => 'ASC'
);
Doing meta_value_num date
instead meta_value_num
didn’t product desired result either. So, my question is, is there a way to sort these events and not filter theme, so every event would be visible and the most current would be displayed first.
Any help or ideas is much appreciated.
Update
adding 'type' => 'DATE',
to media-query
didn’t solve the problem.
Leave an answer