Query to get all events that have not ended.

Home Forums Calendar Products Events Calendar PRO Query to get all events that have not ended.

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #95136
    umediagroup
    Participant

    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?

    #95421
    Julie Kuehl
    Participant

    Hello 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

    #95598
    umediagroup
    Participant

    This reply is private.

    #95638
    Brook
    Participant

    This reply is private.

    #95682
    umediagroup
    Participant

    Brook was that supposed to be for me?

    #97296
    Brook
    Participant

    Howdy 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

    #97308
    umediagroup
    Participant

    All it says for your post is “this reply has been marked as private” so I cant see you answer.

    #97319
    Brook
    Participant

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

    #97378
    umediagroup
    Participant

    I think that will work just fine.

Viewing 9 posts - 1 through 9 (of 9 total)
  • The topic ‘Query to get all events that have not ended.’ is closed to new replies.