In what form is vacancy_end_date
stored in your database by ACF? Make sure you’re asking for the same form. I.e. date('Ymd')
produces 20200421
but your vacancy_end_date
might be stored as unix stamp stamp, which would be a string like 1619028671
so you would never match it.
I do not think you need the 'meta_key' => 'vacancy_end_date',
line in $args
in addition to the meta_query
.
https://generatewp.com/wp_meta_query/ suggests you do:
$meta_query = array(
'relation' => 'OR',
array(
'key' => 'vacancy_end_date',
'value' => $date,
'compare' => '>=',
),
array(
'key' => 'vacancy_end_date',
'value' => '',
'compare' => '=',
),
);
$args = array(
'post_type' => 'vacancy',
'meta_query' => $meta_query,
);
$query = new WP_Query( $args );
You just need to define $date
accurately, as mentioned about.