WP_Query sill shows event after date passed

yes i know this question was asked before. but i do not know what to do.

I`m trying to loop put only upcoming and ongoing events.
i do not know why, but all i get is the events ordered
by start date. no event has been remove from the loop. even if his end date has passed.

the dates stored in ACF fields.

i tried two approaches:
none on them works

$current_date = date_i18n(‘d/m/Y’);
the_field(‘end_date’);
$programs_loop_args = [
‘post_type’ => ‘ye_product’,
‘orderby’ => ‘meta_value_num’,
‘posts_per_page’ => 16,
‘post_status’ => ‘publish’,
‘meta_key’ => ‘start_date’,
‘order’ => ‘ASC’,
‘meta_query’ => [
‘relation’ => ‘AND’ ,
[
‘key’ => ‘end_date’,
‘compare’ => ‘>=’,
‘value’ => $current_date,
‘type’ => ‘date’
]
]
];

or

$current_date = date_i18n(‘d/m/Y’);
echo ‘<br/>’;
the_field(‘end_date’);
$programs_loop_args = [
‘post_type’ => ‘ye_product’,
‘orderby’ => ‘meta_value_num’,
‘posts_per_page’ => 16,
‘post_status’ => ‘publish’,
‘order’ => ‘ASC’,
‘meta_query’ => [
‘relation’ => ‘AND’,
[
‘key’ => ‘start_date’,
‘compare’ => ‘<=’,
‘type’ => ‘date’],
[
‘key’ => ‘end_date’,
‘compare’ => ‘>=’,
‘value’ => $current_date,
‘type’ => ‘date’,
],
],
];

Read more here:: WP_Query sill shows event after date passed

Leave a Reply

Your email address will not be published. Required fields are marked *