Get next future event in a recurring series, from any passed instance view

Home Forums Calendar Products Events Calendar PRO Get next future event in a recurring series, from any passed instance view

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #1147013
    Agustín
    Participant

    I’m integrating the pro version with a theme we made from scratch for center that offers different courses and workshops for children.

    In the single-event.php view of a given recurring course, when the event has passed, I want to show a box saying “hey, make a reservation for the next class which is Friday the 13th” or whatever.

    So I tried to use tribe_get_upcoming_recurring_event_id_from_url() to get the next event info, but it returns the ID of the first event in the series… is this the intended behavior, am I doing something wrong? both?

    Any suggestions on how to do something like this?

    Thanks.

    #1147551
    Geoff
    Member

    Hey Agustin and welcome to the forums!

    This is a great question. Yes, that is the expected behavior for the function and I’m afraid that we do not have a decent function that will grab the next upcoming event instance in the series.

    Instead, I think making a query for the event will be the better way to go. Here’s another thread where someone was able to pull that off using the tribe_get_events() function to build the query.

    I’ll continue looking for specific examples, but will this help get you started in the meantime? Please let me know. 🙂

    Cheers!
    Geoff

    #1147560
    Brook
    Participant

    Howdy Agustín,

    We just wrote a short function that will do this for you:

    https://gist.github.com/elimn/d7bc39b59e4f94946a2bb9faad6ce382

    Pass it the post ID of the event that you are trying to get the next upcoming recurrence for, and it will return the WP_Post for that recurrence if one exists. That do what you wanted?

    Cheers!

    – Brook

    #1147754
    Agustín
    Participant

    Hey, Geoff, thank you for the pointers, in fact I eventually discover tribe_get_events() and made it work. I was gonna post my the solution here at the end of the day but that’s still a few hours away 🙂

    Brook, that’s great! I’ll switch to this solutions as soon as I can.

    Cheers!

    #1147757
    Geoff
    Member

    Heck yeah and thanks for following up, Agustin! Glad this helps — I’ll go ahead and close this thread but please feel free to let us know if any other questions pop up and we’d be happy to help. 🙂

    Cheers!
    Geoff

Viewing 5 posts - 1 through 5 (of 5 total)
  • The topic ‘Get next future event in a recurring series, from any passed instance view’ is closed to new replies.