homemade calendar with ACF – PHP function problem
-
Hi, I’m using an Elementor Pro theme with ACF to make a calendar that matches my client’s wish.
When logged-in users add an event, they can chose if there is an ending date or if the event is one day only (you can’t see that functionnality for now because I changed it after my client created events).
I added a PHP function to see only the events that take place after the day we see the calendar. I achieved it simply when every event had an ending date, but I am struggling with my code to show one-day events.
You can see my code below :
add_action( 'elementor/query/filter_date', function( $query ) { $today = date('Ymd'); $meta_query = $query->get( 'meta_query' ); if(empty('ending_date')){ $meta_query = [ [ 'key' => 'starting_date', 'value' => $today, 'type' => 'DATE', 'compare' => '>=', ] ]; } else { $meta_query = [ [ 'key' => 'ending_date', 'value' => $today, 'type' => 'DATE', 'compare' => '>=', ] ]; } $query->set( 'meta_query', $meta_query ); } );Any idea how I can fix it please?
Thanks
The page I need help with: [log in to see the link]
The topic ‘homemade calendar with ACF – PHP function problem’ is closed to new replies.