I have a custom post type 'events' and I would like to create a Custom Query Filter 'kls-event-liste' for Elementor (https://developers.elementor.com/custom-query-filter/) that only shows upcoming events.
Therefore I added this code to my functions.php:
add_action('elementor/query/kls-event-liste', function($query){
$query->set('orderby', 'meta_value');
$query->set('order', 'ASC');
$meta_query[] = [
'relation' => 'AND',
[
'key' => 'event_start',
'value' => date('d.m.Y - H:i'), //date format set in ACF
'compare' => '>',
'type' => 'DATETIME'
],
];
$query->set( 'meta_query', $meta_query );
});
But it returns ALL events, past and future. When I change compare to '<' no events are shown.
What should I do?
I found out that it works when I change the DATETIME format for event_start in ACF e.g. to Y-m-d H:i:s.
That will work for now but I need to use the german format d.m.Y H:i. Maybe somebody has an idea how get that work?
Thanks, Nico