Display only ongoing events

Home Forums Calendar Products Events Calendar PRO Display only ongoing events

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #958232
    Lars
    Participant

    I am trying to figure out a query for ongoing events. Example: the event start date has passes but the end date has yet to pass. This is a multi day event and I only wish to display events that have already started but have yet to finish.

    $current_date = date(‘j M Y’);
    $args = array (
    ‘post_type’=> ‘tribe_events’,
    ‘start_date’ => $current_date,
    ‘tax_query’ => array(array(
    ‘taxonomy’ => TribeEvents::TAXONOMY,
    ‘field’ => ‘slug’,
    ‘terms’ => ‘exhibition’))
    );

    #958452
    George
    Participant

    Hey Lars,

    This is unfortunately much harder to do than it might seem. I’ve tried for a while to pull this off, to no avail – the trick is that you’d have to set up a range you’re willing to search for events within anyways, which might defeat the purpose of what you’re trying to do here.

    The problem is that you can’t compare date strings in PHP, yet these are how the _eventStartDate and _eventEndDate are stored in The Events Calendar.

    You can compare the Unix Timestamp of these dates, which you might be able to take and work with from there, but you’d have to query a bunch of events first to even have a sample size of events whose dates you could then convert to timestamps for comparison.

    It’s a tricky problem and one that has sparked some ideas on my end of things, and I will bring this up with other developers on our team to see if there’s something to do here to improve this.

    I’m sorry for the disappointment Lars. Please let us know if you have any other questions or concerns!

    — George

    #965257
    Lars
    Participant

    This reply is private.

    #965331
    George
    Participant

    Hey Lars,

    It’s still an interesting issue for sure, but for the next release we have not implemented anything that would necessarily simplify any of this – it is still something that we can definitely improve, however, so stay tuned to plugin updates and the changelogs whenever an update is released.

    In the meantime, the thing I mentioned in my original reply above is still true:

    You can compare the Unix Timestamp of these dates, which you might be able to take and work with from there, but you’d have to query a bunch of events first to even have a sample size of events whose dates you could then convert to timestamps for comparison.

    You shouldn’t need to do MySQL queries to do this – just WP_Query in your PHP files should do, though it will take some coding gymnastics to first pull in a good “sample size” of events and then to efficiently compare their date strings as Timestamps.

    Best of luck with your customizations Lars – I’ll close up this particular thread for now, but if you have other questions or concerns please open a new thread at any time!

    Thank you,
    George

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘Display only ongoing events’ is closed to new replies.