Start_date and End_date not being taken into consideration

Home Forums Calendar Products Events Calendar PRO Start_date and End_date not being taken into consideration

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #1102173
    thecolumbian
    Participant

    Good Afternoon,

    I’m making a custom event search for an admin-side export plugin I’m writing.

    Everything is working as it should, but instead of querying for events between a certain date within a certain category, it shows ALL of the events in the category.

    It doesn’t matter what I put in the ‘start_date’ or ‘end_date’ fields, it doesn’t utilize it.

    		if(isset($_POST['eventExport'])) {
    			$exportEvent['startDate'] = '2016-4-1';  // start_date
    			$exportEvent['endDate'] = '2016-4-30';  // end_date
    			$exportEvent['category'] = $_POST['exportCategory'];
    			$exportPosted = true;
    
    			$exportOptions = array(
    					'start_date' => $exportEvent['startDate'],
    					'end_date' => $exportEvent['endDate'],
    					'eventDisplay' => 'custom',
    					'posts_per_page' => -1,
    					'tax_query' => array(
    						array(
    							'taxonomy' => 'tribe_events_cat',
    							'field' => 'term_id',
    							'terms' => $exportEvent['category']
    							))
    				);
    
    			$events = tribe_get_events($exportOptions);

    Any help would be appreciated

    #1102766
    Brook
    Participant

    Howdy Brandon,

    Great question. tribe_get_events() can be a bit tempermental it seems like. I think all you’re missing is casting those date strings to times. You probably want the beginning of the first day through the end of the last one. If so I would replace them with this code:

    $exportEvent['startDate'] = tribe_beginning_of_day( '2016-4-1' ); // start_date
    $exportEvent['endDate'] = tribe_end_of_day( '2016-4-30' ); // end_date

    Did that help?

    Cheers!

    – Brookq

    #1108848
    Support Droid
    Keymaster

    This topic has not been active for quite some time and will now be closed.

    If you still need assistance please simply open a new topic (linking to this one if necessary)
    and one of the team will be only too happy to help.

Viewing 3 posts - 1 through 3 (of 3 total)
  • The topic ‘Start_date and End_date not being taken into consideration’ is closed to new replies.