'WP_Query and acf date field does not sort right
I am trying to only see posts after or equal to today and sort ASC, my date field outputs Ymd, the first part (only see posts after or equal to today) works but the sorting does not.
$today = date ('Ymd');
$args = array(
'post_type' => 'diensten',
'posts_per_page' => -1,
'meta_query' => array(
array(
'key' => 'datum_dienst',
'value' => $today,
'compare' => '>='
)
),
'meta_key' => 'datum_dienst',
'orderby' => 'meta_value_num',
'order' => 'ASC',
);
$loop = new WP_Query( $args );
Solution 1:[1]
For the few people facing the same problem, here is my very specific solution.
If you have the wordpress plugin Post Types Order installed it will override your order query, i uninstalled it and everything magically worked!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | NSsem |