简体   繁体   中英

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 );

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!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM