Dear Sir/Madam,
Refer to below code, why it always return 0? Custom field wpcf-termination-date is date field
$args = array(
'post_type' => 'member',
'meta_query' => array(
array(
'key' => 'wpcf-termination-date',
'value' => array('2023-05-20', '2023-05-27'),
'compare' => 'BETWEEN',
'type' => 'DATE'
),
),
);
$query = new WP_Query($args);
printf("%s<br>", $query->post_count);
If I do query with below code, it returns 6 records
$args = array(
'post_type' => 'member',
'meta_query' => array(
array(
'key' => 'wpcf-termination-date',
'value' => '',
'compare' => '!='
),
),
);
Hi there,
Toolset stores the dates in Timestamp format. That is why you need to use NUMBER for compare and turn the dates to timestamp:
https://wordpress.stackexchange.com/questions/283867/comparing-timestamps-in-meta-query-doesnt-work
hidden link
Thanks.