Home › Forums › Calendar Products › Events Calendar PRO › Start_date and End_date not being taken into consideration
- This topic has 2 replies, 3 voices, and was last updated 7 years, 12 months ago by Support Droid.
-
AuthorPosts
-
April 13, 2016 at 3:08 pm #1102173thecolumbianParticipant
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
April 14, 2016 at 3:54 pm #1102766BrookParticipantHowdy 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
April 29, 2016 at 9:35 am #1108848Support DroidKeymasterThis 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. -
AuthorPosts
- The topic ‘Start_date and End_date not being taken into consideration’ is closed to new replies.