Home › Forums › Calendar Products › Events Calendar PRO › tribe_get_events returning old events
- This topic has 5 replies, 2 voices, and was last updated 11 years, 7 months ago by
Geoff.
-
AuthorPosts
-
October 7, 2014 at 11:09 am #794491
cmmize
ParticipantI’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?
October 7, 2014 at 3:40 pm #794988Geoff
MemberHi 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!
GeoffOctober 8, 2014 at 9:26 am #796702cmmize
ParticipantThanks, 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,
October 8, 2014 at 9:47 am #796725cmmize
ParticipantI’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.
October 8, 2014 at 10:04 am #796750Geoff
MemberHey 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!
GeoffOctober 17, 2014 at 8:19 am #815980Geoff
MemberHey 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 -
AuthorPosts
- The topic ‘tribe_get_events returning old events’ is closed to new replies.
