元查询比较日期

问题描述 投票:0回答:1

我需要查询日期:-2020-01-06如果此日期(2020-01-06)存在于发布元表的_ from字段中。_ form字段采用时间戳格式,例如1578304800

这就是我正在尝试做的。

$theBookingTime  = strtotime( '2020-01-06' ); 
$events_query = new WP_Query(
                    array(
                        'post_type' => array('yith_booking', 'post'),
                        'meta_query' => array(
                                            array( 'key' => '_from',
                                                   'value' => date('c', $theBookingTime),
                                                   'compare' => '=',
                                                   'type' => 'DATETIME',
                                                  )
                                              )
                         ));
php wordpress plugins meta-query
1个回答
0
投票

尝试下面的代码,让我知道。

将类型更改为数字。

$theBookingTime = strtotime( '2020-01-06' ); 
$events_query   = new WP_Query( 
array(
        'post_type' => 'yith_booking',
        'meta_query' => array(
            array( 
                'key' => '_from',
                'value' => date($theBookingTime),
                'compare'   => '=',
                'type' => 'NUMERIC',
            )
        )
    ) 
);
© www.soinside.com 2019 - 2024. All rights reserved.