date_query empty results with custom post type
I am trying to use get_posts
to return data between certain dates but I always get an empty result even though there is a lot of data. This is for a custom post type.
$args = array(
'post_type' = 'bookings',
'fields' = 'ids',
'post_status' = 'any',
'posts_per_page' = -1,
'date_query' = array(
array(
'after' = '2022-01-01',
'before' = '2022-06-01',
'inclusive' = true,
),
)
);
$data = get_posts($args);
die(var_dump($data));
I also tried something like the below to get a specific date but still an empty array:
'date_query' = array(
array(
'year' = 2022,
'month' = 01,
'day' = 21,
),
)
Topic date-query get-posts wp-query custom-post-types Wordpress
Category Web