Sort custom post type by custom datepicker instead of filtering

Question

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.

0
, , ivan marchenko 4 years 2020-02-06T08:41:21-05:00 0 Answers 78 views 0

Leave an answer

Browse
Browse