发布于 2018-03-19 11:06:23
从Wordpress文档来看,您应该使用以下字符串格式:Y-m-d H:i:s。
因此,元查询可以是:
$meta_query_args = array(
'relation' => 'OR', // Optional, defaults to "AND"
array(
'key' => 'field_key_with_datetime',
'value' => '2018-03-19 08:23:25', // Y-m-d H:i:s format
'compare' => '=',
'type' => 'DATETIME'
)
);
$meta_query = new WP_Meta_Query( $meta_query_args );您可以使用wordpress current_time函数获取当前的DATETIME
$meta_query_args = array(
'relation' => 'OR',
array(
'key' => 'field_key_with_datetime',
'value' => current_time( 'mysql' ), // will return something like '2018-03-19 08:23:25'
'compare' => '=',
'type' => 'DATETIME'
)
);
$meta_query = new WP_Meta_Query( $meta_query_args );来源:time/
https://stackoverflow.com/questions/49360495
复制相似问题