Title: [Plugin: Events Manager] Recurring event link
Last modified: August 21, 2016

---

# [Plugin: Events Manager] Recurring event link

 *  Resolved [Pontus](https://wordpress.org/support/users/jarnlo/)
 * (@jarnlo)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/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?
 * [http://wordpress.org/plugins/events-manager/](http://wordpress.org/plugins/events-manager/)

Viewing 10 replies - 1 through 10 (of 10 total)

 *  Plugin Support [angelo_nwl](https://wordpress.org/support/users/angelo_nwl/)
 * (@angelo_nwl)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/recurring-event-link/#post-4262496)
 * 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](http://wordpress.org/support/topic/recurring-event-link-redirects-wrong-when-individual-event-of-same-name-exists?replies=8)
 *  Thread Starter [Pontus](https://wordpress.org/support/users/jarnlo/)
 * (@jarnlo)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/recurring-event-link/#post-4262501)
 * Thanks, I read it but not wiser
 *  [Philip John](https://wordpress.org/support/users/philipjohn/)
 * (@philipjohn)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/recurring-event-link/#post-4262521)
 * That thread states that it’s a bug in WP so you should follow the bug report 
   linked to for updates.
 * Thanks
 *  Thread Starter [Pontus](https://wordpress.org/support/users/jarnlo/)
 * (@jarnlo)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/recurring-event-link/#post-4262526)
 * 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](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
 *  [caimin_nwl](https://wordpress.org/support/users/caimin_nwl/)
 * (@caimin_nwl)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/recurring-event-link/#post-4262537)
 * 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?
 *  Thread Starter [Pontus](https://wordpress.org/support/users/jarnlo/)
 * (@jarnlo)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/recurring-event-link/#post-4262552)
 * 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
 *  Plugin Support [angelo_nwl](https://wordpress.org/support/users/angelo_nwl/)
 * (@angelo_nwl)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/recurring-event-link/#post-4262579)
 * 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. 01
 * what is happening is:
 * – you are being redirected to Recurr 1 – Oct. 15 instead of the upcoming Oct.
   31 event
 * Is this correct?
 *  Thread Starter [Pontus](https://wordpress.org/support/users/jarnlo/)
 * (@jarnlo)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/recurring-event-link/#post-4262580)
 * YES! Correct
 *  Thread Starter [Pontus](https://wordpress.org/support/users/jarnlo/)
 * (@jarnlo)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/recurring-event-link/#post-4262582)
 * 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'));
       }
       ```
   
 *  [AJD](https://wordpress.org/support/users/ajd/)
 * (@ajd)
 * [11 years, 9 months ago](https://wordpress.org/support/topic/recurring-event-link/#post-4262746)
 * 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.

Viewing 10 replies - 1 through 10 (of 10 total)

The topic ‘[Plugin: Events Manager] Recurring event link’ is closed to new replies.

 * ![](https://ps.w.org/events-manager/assets/icon-256x256.png?rev=1039078)
 * [Events Manager - Calendar, Bookings, Tickets, and more!](https://wordpress.org/plugins/events-manager/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/events-manager/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/events-manager/)
 * [Active Topics](https://wordpress.org/support/plugin/events-manager/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/events-manager/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/events-manager/reviews/)

## Tags

 * [recurring events](https://wordpress.org/support/topic-tag/recurring-events/)

 * 10 replies
 * 5 participants
 * Last reply from: [AJD](https://wordpress.org/support/users/ajd/)
 * Last activity: [11 years, 9 months ago](https://wordpress.org/support/topic/recurring-event-link/#post-4262746)
 * Status: resolved