tribe_get_events returning old events

Home Forums Calendar Products Events Calendar PRO tribe_get_events returning old events

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #794491
    cmmize
    Participant

    I’m trying to get the next 3 events that start on or after today for the next 60 days. Here is the php code:
    $current_date = date(‘j M Y’);
    $end_date = date(‘j M Y’, strtotime(’60 days’));
    $all_events = tribe_get_events(array(
    ‘start_date’=>$current_date,
    ‘end_date’=>$end_date,
    ‘posts_per_page’=>3
    ));

    It returns events that start before the start date when they end after the start date. Any reason why this is happening?

    #794988
    Geoff
    Member

    Hi there, Charles! Thanks for getting in touch and sorry you’re running into some trouble here. Hopefully we can figure it out together. 🙂

    The tribe_get_events() function works a lot like the WordPress get_posts() function. To get the next three upcoming events, you could try something like:

    <?php global $post;
    $events = tribe_get_events(array(
    'eventDisplay'=>'upcoming',
    'posts_per_page'=>3
    ));

    That will fetch the next three events that scheduled on the calendar relative to the current day.

    Does that make sense? Will that work for you? Please let me know. 🙂

    Cheers!
    Geoff

    #796702
    cmmize
    Participant

    Thanks, that did work.. which leads me to ask, where is the documentation for the fields/values that can be sorted/selected in the tribe_get_events function? This has nothing in it to reference(http://docs.tri.be/Events-Calendar/function-tribe_get_events.html). Thanks,

    #796725
    cmmize
    Participant

    I’m sorry Geoff, I didn’t see how to edit my previous response. But I spoke too soon, that is still pulling in events with date ranges in todays date.

    #796750
    Geoff
    Member

    Hey Charles, thanks for following up!

    where is the documentation for the fields/values that can be sorted/selected in the tribe_get_events function?

    The function plays off the same variables and parameters as the default WordPress get_posts() function. If you’re familiar with that, then you can customize the tribe_get_events() function similarly.

    But I spoke too soon, that is still pulling in events with date ranges in todays date.

    Sorry, that snippet didn’t take the current day into account. But since it’s just playing with the global post query, you should be able to modify the output using date parameters the same way you would in a default WordPress query. Here’s the WordPress Codex documentation for that.

    Does that help answer your question? Please let mew know 🙂

    Cheers!
    Geoff

     

    #815980
    Geoff
    Member

    Hey there, Charles! It’s been a while so I’m going to go ahead and close this thread. If we can help with anything else, though, please don’t hesitate to create new a new thread and we’ll help you out. 🙂

    Cheers!
    Geoff

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘tribe_get_events returning old events’ is closed to new replies.