Backstory
We have a bunch of events inside an events
custom post type. They each have the following custom fields associated to them:
start_date
end_date
On the front-end, we have a sidebar with filters where the user can choose how they want to search events (ie., various taxonomies, start date for their trip in town, end date, etc). The event_begin
and event_end
search inputs are what we'll use to query the database off of.
The problem
I'm having issues including a loosely queried result. Strict matches show up, but the stakeholder for the project is saying that the search is too strict. I've brought up the concept of abandoning the front-end event_end
field in the user's search filters, but I'm not entirely sure that's necessary at this point myself.
If I search for events, I can structure my meta_query
where:
- events with a start date and end date between the two chosen dates will show up
- events where the start date occurs between the two chosen dates will show up
- events where the end date occurs between the two chosen dates will show up
But what about when I front-end search like this:
event_begin
7/15/2016event_end
7/15/2016
...but have an event in the database where its custom fields show the event to actually be one week long 7/11/2016 - 7/16/2016.
That event wouldn't return from my query, because none of the above matches. But technically if I'm in town on 7/15/2016 (today), I should be able to see (and possibly attend) that event while in town on business for the day.
Thoughts
Generally, we don't store an event range as separate dates for each day in the series. We (as humans) store date ranges; so I'm sure there's some logical way to approach this. Just not coming up with anything in my searching or research.
Thank you for your help and thoughts!