Support

Home Forums Event Espresso Premium One recurring event per page in Event List

One recurring event per page in Event List

Posted: January 14, 2014 at 12:02 am

Viewing 2 reply threads


Robin Jennings

January 14, 2014 at 12:02 am

I’ve been trying to create a main event page which has an overview of all events but only 1 occurrence of each recurring event.

As a work around I have created an Event List with recurrence set to “false” and then manually added the recurring events as single events. Is there anyway to just have one event listing for each recurring event?

[EVENT_LIST show_expired=”false” show_recurrence=”false”]
[SINGLEEVENT single_event_id=”XYZ”]
[SINGLEEVENT single_event_id=”ABC”]

As seen here: http://www.match.vic.edu.au/courses/

At the end of this list is the recurring events. They are displaying the full registration form. Is there a way to just show the snippet similar to the other events above it.

Thanks for your help!


Josh

  • Support Staff

January 14, 2014 at 8:39 am

Hi there,

I’m afraid that if you use the singleevent shortcode on the the same page as the event_list shortcode ther isn’t a way to show just the snippet.

There is a way to programmatically only display the first event of the series with the event list shortcode.

First, you’ll need to change the show_recurrence parameter to true. Then you’ll add this function to to your custom file add-on’s custom_functions.php file or in a custom snippet plugin

// function to help display only the first event in a recurring event series
function get_recurrence_info( $recurrence_id = FALSE )
{
    $recurrence_info = '';
    if ( $recurrence_id )
    {
        global $wpdb;
        $r = $wpdb->get_results('SELECT * FROM ' . EVENT_ESPRESSO_RECURRENCE_TABLE . ' WHERE recurrence_id="'.$recurrence_id.'"');
        if ($wpdb->num_rows > 0)
                $recurrence_info = $r[0];
    }
    return $recurrence_info;
}

then you can open your wp-content\uploads\espresso\templates\event_list.php file, and locate the event_espresso_get_event_details function (around line 29 in my file) and just after the line 275 where it says:

foreach ($events as $event) {

You add:

$r = get_recurrence_info( $event->recurrence_id );
if ( $event->recurrence_id == 0 || $r->recurrence_start_date == $event->start_date ) {

and then add the closing curly brace at the end of the function

}

This will allow all non-recurring events to be displayed as well as the first event from a series of recurring events.


Robin Jennings

January 15, 2014 at 8:27 pm

Thanks Josh. I believe I’ve followed your instructions to no avail. The file is in the templates folder is called ‘ongoing_event_list.php’. Is that the correct file to modify?


Josh

  • Support Staff

January 15, 2014 at 8:30 pm

No, the correct file is \templates\event_list.php. You can copy it and the event_list_display.php file to wp-content\uploads\espresso\templates\ to keep the files safe from getting overwritten on an update.

Viewing 2 reply threads

The support post ‘One recurring event per page in Event List’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso