tribe_get_events and future recurring events when first has passed

Home Forums Calendar Products Events Calendar PRO tribe_get_events and future recurring events when first has passed

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1145096
    renaissancecreative
    Participant

    Hi,

    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,
    )
    )
    ));

    #1145309
    Brook
    Participant

    Howdy 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

    #1145454
    renaissancecreative
    Participant

    Hi 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?

    #1146179
    Brook
    Participant

    Howdy 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

    #1148897
    renaissancecreative
    Participant

    Hi 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

    #1149311
    Brook
    Participant

    Excellent! 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

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘tribe_get_events and future recurring events when first has passed’ is closed to new replies.