I’ve tried a couple of other plugins and spent hours making it work after some testing only to find there were other issues that have just made me give up on them (like re-occurring events not showing up the following year).
Anyway, I’m doing some testing now on this plugin (since it was designed to show past events) to see if it will work for our needs. What I would like to show on our genealogy site is what events happened today in the past. If I can make them show up (I’ve tried as many shortcode variations as I can think of) then I thought I would do a custom format showing just the year next to the title, displayed in a widget with a widget title something like ‘Today in History’
Before I go any further any help would be greatly appreciated.
Charles Winders
I hope you find Event Organiser a bit more bug free :).
As for the ‘Today in History’ events – it’s possible to show events that happened today, last year (say), by using the relative date formats. Untested, but the following should work;
$event = eo_get_events(array(
'event_start_before'=>'-1 year',
'event_start_after'=> '+1 day -1 year',
'showpastevents'=> true, //Set this just to true just to be sure.
));
(or you can use the shortcode attributes).
However, more generally its a little more difficult – because the database isn’t designed for queries like that (dates are stored as Y-m-d
, rather than the day, month and year separately – which is the kind of set-up you would ideally have ideally for this use-case.
There are ways round this… You can (programatically) perform a query for each day – going back as far as you need to. But each year is a new query so this is not ideal. Obviously you would cache the results, but this would only work well if you are very limited in the number of years you have to go back.
Alternatively see this http://stackoverflow.com/questions/10416266/how-to-compare-date-month-year-with-another-date-month-year – Event dates are stored as SQL DATES, so you could create a custom SQL query to compare the month and day parts of the dates.
Since this would require custom code – there’s no way of using the shortcodes for this, unless you create your own.
Stephen Harris
Yeah, I can see where that’s going to be an issue comparing dates. Tried to put that small query in a function without success. Used it as a shortcode and still got all the past events regardless of what today is. I think I’ll skip this add on for now, Christmas is coming and got to get this done for the wife’s family!
Thanks for your ideas Stephen!
Charles Winders
Actually the start before / after should be switched. Looking at it I’d expect it return no events. After testing that is what happens. The following gives events on today, but last year:
$events = eo_get_events(array(
'event_start_before'=>'+1 day -1 year',
'event_start_after'=> '-1 year',
'showpastevents'=> true, //Set this just to true just to be sure.
));
Stephen Harris