I don’t think this is possible with php, so I did it with jQuery. I added the occurrence date to a parameter on the url and then grabbed that and stuck it in the html, so that both the recurring and the non-recurring have similar date formatting in the entry header area. I believe I’ve hunted through your codex and couldn’t find anything that did this. Did I miss something?
Joy Katzen-Guthrie
No, the plug-in doesn’t render date-specific pages for the recurring events. The one page serves all occurrences.
That said, there’s nothing wrong with you’re doing. Event Organiser doesn’t do this by default because it can’t, generally, and reliably insert the date parameter in every instance of links to the event page.
I would however recommend that you use the occurrence ID in the URL rather than formatted date, and just inserting that. Doing so means if someone were to alter the URL and change the date it would appear the event is occurring on a date that is not. Even if that seems unlikely, someone might bookmark the URL, and then the occurrence is removed/changed; that user would visit the URL and it would look like the event is still running on that date. Lastly, you’re probably escaping the formatted date before rendering it, but sanitising an occurrence ID (an integer) is far more straightforward and restrictive.
By using an occurrence ID you can display the correct (and possibly changed) datetime and you can easily check if the occurrence ID is invalid and display an error message / redirect to 404 / display the default event page if it’s not.
Once you retrieve the occurrence ID:
try {
$formattedDate = eo_get_the_start( 'M d, Y', get_the_ID(), (int) $occurrence_id );
//print formatted date.
} catch ( \Exception $e ) {
//invalid occurrence ID
}
Stephen Harris