[Plugin: Events Manager] Recurring event link
-
In my event list I filter out recurrences of recurring events in order to show one post per recurring event. The permalink for the event becomes yoursite/events-recurring/exampleevent/ and redirects to the first occurence in the series. I want to override this and make it link to the next occurence (by date) instead. Any ideas?
-
here’s another thread which may help you with this – http://wordpress.org/support/topic/recurring-event-link-redirects-wrong-when-individual-event-of-same-name-exists?replies=8
Thanks, I read it but not wiser
That thread states that it’s a bug in WP so you should follow the bug report linked to for updates.
Thanks
Sorry if I’m missing something here but I can’t see that I’m facing the same problem as the thread-starter in the referenced thread…
Once again:
I have both events and recurring events. In my “upcoming events-list” I want to output future events, both standard and recurring ones. As I don’t want duplicates in the list I filter out recurrences and show only the “mother-event” for recurring events. the #_EVENTLINK for the mother-event points to yoursite/events-recurring/exampleevent/ which is correct. When I click that link wordpress/eventsmanager redirects to yoursite/events/exampleevent-2013-04-01/, where the date is the date of the first recurrence. This also is the correct behaviour (according to the referenced post (http://wordpress.org/support/topic/recurring-event-link-redirects-wrong-when-individual-event-of-same-name-exists?replies=8). What I want instead is to redirect, not the first recurrence, but to the first future recurrence.
correct me if I’m wrong
Sorry, I’m not 100% I follow what you’re trying to do.
Are you saying that in a sequence of recurring events – let’s call them Event 1, Event 2 and Event 3 – all EM/WP generated links for Event 1 should be redirected to Event 2?
And when Event 1 has passed, links to Event 2 should be redirected to Event 3?
This is my IRL scenario:
I have an event recurring every saturday and sunday from June 1st to November 2nd.This is my EM setup:
I set up an recurring event, taking place saturdays and sundays from June 1st to November 2nd.The permalink for my newly added recurring event is mysite.com/events-recurring/my-recurring-event/
This action created a range of events with permalinks spanning from
mysite.com/events/my-recurring-event-2013-06-01/ to mysite.com/events/my-recurring-event-2013-11-02/By default this gives me one post for every occurrence of this event in the event-list. Now I filter out the recurrences of this event by the following code in events-list.php:
// get recurrence events $args['recurring']=1; $evts_recurring=EM_Events::get($args); // get non-recurrence events $args['recurring']=0; $evts=EM_Events::get($args); // filter out the events that are instances of recurring events $non_recurrence_evts = array_filter($evts,'is_no_recurrence'); // merge recurrence and non-recurring events $evts_all= array_merge($non_recurrence_evts,$evts_recurring); // sort them by start==start date+time usort($evts_all,'evt_start_sort'); . . . . echo EM_Events::output( $evts_all, $args );and in functions.php:
function is_no_recurrence($evt) { return $evt->recurrence_id == null; }the format for my event-list holds the following:
<h3 class="event-title"><a href="#_EVENTURL">#_EVENTNAME</a></h3>Now this gives me an event-list with just one post (the template for the recurring events)
the #_EVENTURL links to mysite.com/events-recurring/my-recurring-event/. When I click this link I am redirected to mysite.com/events/my-recurring-event-2013-06-01/. However I want to change this to redirect to the next not yet taken place occurrence. If I click the post today (2013-10-28) I want it to redirect to mysite.com/events/my-recurring-event-2013-11-01/ because that is the next occurrence not yet taken place.Please excuse my poor English
I see what you mean now, you have a recurring event like
Recurr 1 – Oct. 15
Recurr 2 – Oct. 20
Recurr 3 – Oct. 31
Recurr 4 – Nov. 01what is happening is:
– you are being redirected to Recurr 1 – Oct. 15 instead of the upcoming Oct. 31 event
Is this correct?
YES! Correct
Solved by doing the following:
In events-list.php
// get recurrence events $args['recurring']=1; $evts_recurring=EM_Events::get($args); // get first future recurrence events $nextRecurrences = nextRecurrences($evts_recurring); // get non-recurrence events $args['recurring']=0; $evts=EM_Events::get($args); // filter out the events that are instances of recurring events $non_recurrence_evts = array_filter($evts,'is_no_recurrence'); // merge nextRecurrences and non-recurring events $evts_all= array_merge($non_recurrence_evts,$nextRecurrences);and in functions.php
function is_no_recurrence($evt) { return $evt->recurrence_id == null; } function nextRecurrences($evts) { $nextRecurrences = array(); foreach ($evts as $evt) { array_push($nextRecurrences,reset(nextRecurrenceOf($evt))); } return $nextRecurrences; } function nextRecurrenceOf($evt){ return EM_Events::get(array('recurrence_id'=>$evt->event_id, 'limit'=>1, 'scope'=>'future', 'orderby'=>'event_start_date', 'order'=>'ASC')); }Hi this looks like a promising solution to display recurring events as a single event.
Is there a way to implement this without hacking the plugin? Perhaps a template override or hook/filter?
Thanks.
The topic ‘[Plugin: Events Manager] Recurring event link’ is closed to new replies.