Create a list of event ID's with recurring events added only once
-
I have been finding many different solutions for listing events but limiting recurring events to only show once. Here is one solution. In this case I needed to output the event Post ID’s to use in a slider plugin.
//Create a list of event IDs, with recurring events only added one time if (class_exists('EM_Events')) { //assign non-recurring event IDs to an array $notRecur = EM_Events::get( array('scope' => 'future' )); foreach($notRecur as $EM_Event){ if (!$EM_Event->is_recurrence()){ $ID_NotRecur[]= $EM_Event->output('#_EVENTPOSTID'); } } //assign recurring event template IDs to an array $Recur = EM_Events::get( array('scope' => 'future' , 'recurring'=>'1' )); foreach($Recur as $EM_Event){ $ID_Recur[]= $EM_Event->output('#_EVENTPOSTID'); } } //merge the arrays $ID_EMPost = array_merge($ID_NotRecur, $ID_Recur); //check the output echo implode (' , ', $ID_EMPost);
Note: This gets the post id of the ‘event-recurring’ custom post type recurring event template, rather than an instance of a recurring event.
https://wordpress.org/plugins/events-manager/
- The topic ‘Create a list of event ID's with recurring events added only once’ is closed to new replies.