wp query - Comparing Meta Field date in WPQuery using Meta_Query?

I have dates stored in the format d-m-Y, and i want to display any posts that are in the past, before today.$args = arra

I have dates stored in the format d-m-Y, and i want to display any posts that are in the past, before today.

    $args = array (
        'post_type'=>'property',
        'post_status'=>'publish',
        'posts_per_page'=> 8,
        'paged'=> $paged,
        'meta_query' => array(
            'key' => 'auction_date',
            'value' => date( 'd-m-Y'),
            'compare' => '<',
            'type' => 'DATE'
        ),
      );

This doesn't seem to work and i can't figure out why. Any suggestions would be much appreciated.

I have dates stored in the format d-m-Y, and i want to display any posts that are in the past, before today.

    $args = array (
        'post_type'=>'property',
        'post_status'=>'publish',
        'posts_per_page'=> 8,
        'paged'=> $paged,
        'meta_query' => array(
            'key' => 'auction_date',
            'value' => date( 'd-m-Y'),
            'compare' => '<',
            'type' => 'DATE'
        ),
      );

This doesn't seem to work and i can't figure out why. Any suggestions would be much appreciated.

Share Improve this question asked Jan 30, 2020 at 11:12 reigns1989reigns1989 171 silver badge6 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

ACF stores it's dates in Ymd format, this is why i couldn't compare.

Make sure your date is in Ymd format when you compare it against an ACF datefield.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742412992a4439185.html

相关推荐

  • wp query - Comparing Meta Field date in WPQuery using Meta_Query?

    I have dates stored in the format d-m-Y, and i want to display any posts that are in the past, before today.$args = arra

    5小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信