Title: Pontus's Replies | WordPress.org

---

# Pontus

  [  ](https://wordpress.org/support/users/jarnlo/)

 *   [Profile](https://wordpress.org/support/users/jarnlo/)
 *   [Topics Started](https://wordpress.org/support/users/jarnlo/topics/)
 *   [Replies Created](https://wordpress.org/support/users/jarnlo/replies/)
 *   [Reviews Written](https://wordpress.org/support/users/jarnlo/reviews/)
 *   [Topics Replied To](https://wordpress.org/support/users/jarnlo/replied-to/)
 *   [Engagements](https://wordpress.org/support/users/jarnlo/engagements/)
 *   [Favorites](https://wordpress.org/support/users/jarnlo/favorites/)

 Search replies:

## Forum Replies Created

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

 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Events Manager - Calendar, Bookings, Tickets, and more!] [Plugin: Events Manager] Recurring event link](https://wordpress.org/support/topic/recurring-event-link/)
 *  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'));
       }
       ```
   
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Events Manager - Calendar, Bookings, Tickets, and more!] [Plugin: Events Manager] Recurring event link](https://wordpress.org/support/topic/recurring-event-link/)
 *  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
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Events Manager - Calendar, Bookings, Tickets, and more!] [Plugin: Events Manager] Recurring event link](https://wordpress.org/support/topic/recurring-event-link/)
 *  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
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Events Manager - Calendar, Bookings, Tickets, and more!] [Plugin: Events Manager] Recurring event link](https://wordpress.org/support/topic/recurring-event-link/)
 *  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
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Events Manager - Calendar, Bookings, Tickets, and more!] [Plugin: Events Manager] Recurring event link](https://wordpress.org/support/topic/recurring-event-link/)
 *  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

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