Show last occurrence of an event in list/photo views and single post

Home Forums Calendar Products Events Calendar PRO Show last occurrence of an event in list/photo views and single post

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #1535270
    ccian
    Participant

    Is it possible for a recurring event to show the last occurrence?

    e.g. currently is shows

    JUNE 22-9:00 AM – 5:00 PM Free

    I would like it to say

    JUNE 22-July 6 – 9:00 AM – 5:00 PM Free

    #1536253
    Sky
    Keymaster

    Hi there,

    Thanks for reaching out. I will try to help with this.

    Your request is not possible by default. You could create a custom template to add this information, but it will take some knowledge of PHP. We are limited in the amount of support we can provide for customization here on the support forums, but I will try to get you going in the right direction.

    Here’s a snippet to get you started:

    <?php
    $the_current_post_id = get_the_ID();
    if( tribe_is_recurring_event($the_current_post_id) ) {
    $parent_id = wp_get_post_parent_id( $the_current_post_id );
    $my_event_id = ($parent_id) ? $parent_id : $the_current_post_id;

    $recurrence_args = array(
    'post_parent' => $my_event_id,
    'meta_key' => '_EventEndDate',
    'orderby' => 'meta_key',
    'order' => 'ASC',
    'fields' => 'ids',
    'posts_per_page' => -1,
    );
    $all_events = tribe_get_events( $recurrence_args );
    $last_event_in_series = end($all_events);
    $the_end = tribe_get_end_date($last_event_in_series);

    $final_date = date( get_option('date_format'), strtotime($the_end) );
    echo "The last event takes place on $final_date.";
    }
    ?>

    You would need to modify this to work with the template you want to customize. You can read more about customizing event templates in our Themer’s Guide.

    Hope that helps! Let me know if you have any other questions.

    Thanks,
    Sky

    #1552468
    Support Droid
    Keymaster

    Hey there! This thread has been pretty quiet for the last three weeks, so we’re going to go ahead and close it to avoid confusion with other topics. If you’re still looking for help with this, please do open a new thread, reference this one and we’d be more than happy to continue the conversation over there.

    Thanks so much!
    The Events Calendar Support Team

Viewing 3 posts - 1 through 3 (of 3 total)
  • The topic ‘Show last occurrence of an event in list/photo views and single post’ is closed to new replies.