I've inherited a website with a post type courses that has a custom field 'date-start', a Date Picker.
Unfortunately the date start is stored as 'ddmmyy' and the ACF documentation implies that this code works with 'yymmdd'
Now I can't change all dates to this format because there's lots of dependent code.
So how do I get this query to work - to order the posts in order based on the 'date-start' custom field? It doesn't work with order as DESC or order as ASC. The output appears to be random order.
$posts = get_posts(array(
'post_type' => 'course',
'posts_per_page' => -1,
'meta_key' => 'date-start',
'orderby' => 'meta_value_num',
'order' => 'DESC'
));
pre_get_posts
to display posts that haven't reached their publish date yet if you want to go down that road. Forcing WP to try and fit a non-standard format is unnecessary