Sorry for the bad title, had difficulties phrasing this questioon in a TLDR fashion.
I have a custom post type for events on my website. Some events only happen in one day, whilst other events might last several days. I want the website to hide events that has passed. This I’ve done so far by basing it off event_startdate. But I want to adjust my query to basically do this: "If event_enddate is empty, show events where event_startdate has not passed. If event_enddate has a value, show events where event_enddate has not passed".
My current query which works fine based only on the startdate:
$query->set( 'meta_key', 'event_startdate' );
$query->set( 'orderby', 'meta_value' );
$query->set( 'order', 'ASC' );
$query->set( 'meta_query', array(
array(
'key' => 'event_startdate',
'type' => 'DATE',
'value' => date("Y.m.d"),
'compare' => '>='
)
)
);
});
In "oldschool PHP" this would not be a problem for me, but I’m fairly new to WordPress developing. Thanks in advance for any help!