Hi jnhghy,
There isn’t a function provided for this so you’ll need to use SQL.
If the event is recurring on each of the 3 days then that would be fairly easy. If its a single event spanning 3 days, then its a bit more tricky since the database only contains the date/times of the occurrences of events, not the days on which an event exists. Should still be possible though.
… In the second case a work-around would be to query the first event which ends after 2013.11.17: in your example, its the same event (which ends at the end of the 19th: a 3 day event). Then take its start date (17th). Then the next ‘event day’ is somewhere between 17th-19th (inclusive). Simply loop through the days to find the date after the one we started with (17th), and you end up with the 18th.
If the original event only lasted the one day and the next event ran from 2013.12.02-2013.12.04 (for example). We would know the next ‘event day’ is between 2nd-4th (December). The earliest date after the one we started with (17th Nov) in this case would be the 2nd.
Thread Starter
jnhghy
(@jnhghy)
Thanks for your time.
I’ve tried what you said and hit an issue:
If there is a long lasting event (1 month) and some intermediar events (2-3 days events) querying for the closest start and end dates will not do the trick. An example of what I’m saying here: img
Looking at some code examples I’ve seen the “ondate” argument for query-ing events. Do you know how does that one work? can it be splited out from the query and be made a verification on it? so I can loop 3 – n days and just check if date has events.
Thanks
mmm… yeah didn’t think about that…
The ‘ondate’ works by querying events which are active during that time-frame. E.g. if ondate is to ‘2013-01’ it will query events that start before (and including) Janurary 31st and after (and including) Janurary 1st (2013).
Similarly with ondate set to ‘2013-01-14’ or ‘2013’ (date and year respectively). But you’re not querying events here, you’re querying dates.
As a correction to the above you could query events which end after the current date, and sort by start date (which is default).
Otherwise, I think you may have to go down the SQL route. (this might be helpful: http://stackoverflow.com/questions/1378593/get-a-list-of-dates-between-two-dates-using-a-function).
Keep in mind that the relative date queries are inclusive.
Thread Starter
jnhghy
(@jnhghy)
I had a look at the thread on stackoverflow but at this point I’m thinking to save each event day (if an events tarts on 3rd and ends on 7th then save 3,4,5,6,7) as post/event meta this way I’d be able to get all the posts that have an exact date as post_meta (doable using wp_Query) I think this wouldn’t be very healthy for the database but with such a request and using wordpress I’m thinking it’s normal for the database to suffer… will coded it tommorow and let you know how it looks, in the mean time if you have any advice … feel free to share it (espacially if you think this is not a good idea.)
Regards