Home › Forums › Calendar Products › Events Calendar PRO › Query to get all events that have not ended.
- This topic has 8 replies, 3 voices, and was last updated 10 years, 3 months ago by umediagroup.
-
AuthorPosts
-
January 21, 2014 at 7:13 am #95136umediagroupParticipant
I’m currently trying to do this.
$recent = new WP_Query(array(‘tag’ => ‘event-featured’, ‘posts_per_page’ => get_option(‘mvp_slider_num’), ‘post_type’ => ‘tribe_events’,
‘meta_query’ => array(
array(
‘key’ => ‘_EventEndDate’,
‘value’ => date(‘Y-m-d h:m:s’),
‘compare’ => ‘<=’
)
),
‘orderby’ => ‘_EventEndDate’,
‘order’ => ‘ASC’ ));but for some reason thats not working. It works fine if you replace _EventEndDate with _EventStartDate and <= with >= to get all future events.
So how would one query to get all events who’s end dates have not yet passed?
January 21, 2014 at 4:39 pm #95421Julie KuehlParticipantHello umediagroup,
This doesn’t quite look like a pre-sales question. I’m going to move it over to our PRO forum, if you don’t mind.
— Julie
January 22, 2014 at 6:22 am #95598umediagroupParticipantThis reply is private.
January 22, 2014 at 7:38 am #95638BrookParticipantThis reply is private.
January 22, 2014 at 10:24 am #95682umediagroupParticipantBrook was that supposed to be for me?
January 27, 2014 at 9:19 am #97296BrookParticipantHowdy umediagroup,
Yes that response was intended for you. I am one of the gents that handles Pro questions. Apologies for my belated reply. We are having a bit of trouble with our forums ATM, it seems like 99% of the time they notify us of responses, but that 1% causes delays like this.
Did my above response help you?
– B rook
January 27, 2014 at 9:31 am #97308umediagroupParticipantAll it says for your post is “this reply has been marked as private” so I cant see you answer.
January 27, 2014 at 9:46 am #97319BrookParticipantOi! That should not have been hidden from you. Here is a copy of it.
Howdy umediagroup,
Attempting to create a query to do what you want is no easy task. You need look no further than our TribeEventsQuery class to see how complex it can be. Your own query will not actually sort by end date for instance, as that is not an actual column.
This is why we provide the function tribe_get_events() to handle all the you crazy complexities for you. This query will get events for the next year that have not yet finished. Note that the return of tribe_get_events() is an array of post_objects, not a WP_Query. Would that work for you?
I hope that helps. Please let me know if you have more questions.
– Brook
January 27, 2014 at 11:04 am #97378umediagroupParticipantI think that will work just fine.
-
AuthorPosts
- The topic ‘Query to get all events that have not ended.’ is closed to new replies.