How to display the last date of a recurring event?

Home Forums Calendar Products Events Calendar PRO How to display the last date of a recurring event?

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #1337606
    Barbara
    Participant

    I’m trying to display the last date for a recurring event but there doesn’t seem to be a straight forward method on how to do this.

    For example, I have a recurring event series starting from October 6th, 2017 to November 3rd, 2017. I’m trying to display the “November 3rd, 2017”.

    I’m using: return tribe_get_start_date() . ' until ' . tribe_get_end_date();

    But that just returns “October 6th, 2017 until October 6th, 2017”.

    I’ve scoured the forums in search for a solution for this but it seems like it’s not possible with Event Calendar PRO. This seems like it should be a more common feature. Any help would be much appreciated.

    #1338350
    Victor
    Keymaster

    Hi Barbara!

    Thanks for reaching out to us! 🙂

    I’d be happy to help you with that.

    The tribe_get_end_date() function will only return the end date for the the current event, and not the last instance of that recurring event.

    Each instance of a recurring event is a child event of the main event, just like a child post is to its parent post.

    One approach to achieve what you’re looking for would be to first fetch the last instance for the event and then you could use the tribe_get_end_date() function to serve the date for that instance.

    I hope that helps! Let me know if you have other questions.

    Best,
    Victor

    #1341755
    Barbara
    Participant

    Hi Victor,

    Thank you for your response!

    How would I go about fetching the last instance for the event?

    #1342156
    Victor
    Keymaster

    Hi Barbara,

    First, please note that we are limited in how much support we can give for custom development questions like this.

    That said, we always like helping out and at least point users into the right direction as much possible.

    You could make use of the tribe_get_events() helper function. We have a great article on how to use it here > https://theeventscalendar.com/knowledgebase/using-tribe_get_events/

    I’m not sure where exactly you want to show this information, but here’s an example you can use as a reference:

    /* Get all child events ids in a recurrence series */
    $recurrence_parent_id = get_the_ID();
    $recurrence_args = array(
    'post_parent'    => $recurrence_parent_id,
    'meta_key'       => '_EventEndDate',
    'orderby'        => 'meta_key',
    'order'          => 'ASC',
    'fields'         => 'ids',
    'posts_per_page' => -1,
    );
    $all_event_ids_in_recurrence_series = tribe_get_events( $recurrence_args );

    I hope that helps! Let me know if you have other questions.

    Best,
    Victor

    #1352043
    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 5 posts - 1 through 5 (of 5 total)
  • The topic ‘How to display the last date of a recurring event?’ is closed to new replies.