Home › Forums › Calendar Products › Events Calendar PRO › tribe_get_events and future recurring events when first has passed
- This topic has 6 replies, 3 voices, and was last updated 9 years, 9 months ago by
Brook.
-
AuthorPosts
-
July 28, 2016 at 7:43 am #1145096
renaissancecreative
ParticipantHi,
I have developed a site and utilising this plugin and it works really well, however I need to show the current and future events that run on a recurring basis, but hide recurring events that have passed.
$events = tribe_get_events( array(
'posts_per_page' => 25,
'eventDisplay' => 'custom',
'post_parent__in' => array( 0 ),
'start_date' => '2016-07-01', //put this in as the events that should show start on the 9th July, if I put today they don't show.
'tax_query' => array(
'relation' => 'OR',
array(
'taxonomy' => 'tribe_events_cat',
'field' => 'term_id',
'terms' => $tax,
)
)
));
July 28, 2016 at 1:22 pm #1145309Brook
ParticipantHowdy renaissancecreative,
I would love to help you find a solution for this.
So your current code should be working. It will retrieve ongoing events, namely events which have started but not yet ended. And events that have not started yet. It will show 25 of those sorted by start date. Is this not the behavior you’re expecting? Are you trying to exclude ongoing events?
Cheers!
– Brook
July 29, 2016 at 1:00 am #1145454renaissancecreative
ParticipantHi Brook,
Sorry I think I got distracted when writing this out.
In terms of the code, this is working however I want to change hardcoding the date to be today’s date, but when I do this it doesn’t show any recurring events that are still ongoing, it only shows events that the first occurence is today or after today.
Does that make more sense?
August 1, 2016 at 10:47 am #1146179Brook
ParticipantHowdy dendis84,
Of course, that does make complete sense. To remedy this I would replace the following in your call to tribe_get_events() :
'start_date' => '2016-07-01',
With:
'start_date' => date( 'Y-m-d H:i:s' ),
The date function will fill in today’s date/time and show any events from this point forward.
Did that do the trick?
Cheers!
– Brook
August 8, 2016 at 3:14 am #1148897renaissancecreative
ParticipantHi Brook,
Sorry didn’t get back sooner, you response got lost in my inbox.
I didn’t quite understand what you were asking me to do, but I can it another try by creating a variable of
$today = date('Y-m-d-');Then changed the args in tribe_get_events to be
$events = tribe_get_events( array( 'posts_per_page' => 25, 'eventDisplay' => 'custom', 'post_parent__in' => array( 0 ), 'start_date' => $today, 'tax_query' => array( 'relation' => 'OR', array( 'taxonomy' => 'tribe_events_cat', 'field' => 'term_id', 'terms' => $tax, ) ) ));Hope this helps if anyone else has this sort of issue.
James
August 8, 2016 at 11:43 pm #1149311Brook
ParticipantExcellent! I am happy you got that sorted. That is a very good idea what you did.
I am sorry my last response got a little mangled by our HTML editor, causing it to show erroneous characters in my code. I just fixed it for posterity. But your solution will work good for showing all events from today forward.
Thank you for getting back! Cheers!
– Brook
-
AuthorPosts
- The topic ‘tribe_get_events and future recurring events when first has passed’ is closed to new replies.
