meta_value_date & sorting not working
-
I’m fetching a custom post type called ‘event’ and am using a plugin called ACF to add a custom field (of type ‘date picker’) within the WP editor for this post type. Using the query below I’m fetching ‘events’ and ordering them or trying to at least.
$eventQuery = new WP_Query(array('post_type'=>'event', 'posts_per_page'=>-1, 'order'=>'asc', 'orderby'=>'meta_value_date', 'meta_key'=>'event_date'));
The problem is the ‘events’ are not being sorted correctly unless I change the type from ‘meta_value_date’ to ‘meta_value_num’ for the sort. According to the documentation ‘date picker’ in ACF stores dates in the DB as ‘YYYYMMDD’ so one can see why ‘meta_value_num’ works but why does ‘meta_value_date’ equally not work as a WP query??
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘meta_value_date & sorting not working’ is closed to new replies.