Help Desk

filtering shows past events

  • Posts: 14 Topics: 4
    | Permalink

    Hi,

    This is a continuation of this issue: https://theeventscalendar.com/support/forums/topic/filtering-now-shows-past-events/ For some reason your private responses aren’t shown to me, even though they’re in my thread and I’m logged in. Anyway, as you’ll see there:

    1. The issue is that when filtering is applied, past events are shown.
    2. I went through very extensive testing (plugin / theme conflicts, etc.).
    3. In the end, because the Filter Bar update had completely broken our customisations, we decided on a radical approach of ditching all our customisations (which were extensive and working fine until your latest update – it was decided we were spending too much time managing clashes between updates and customisations, though, and the customisations are the only part of the process we have control over). We’ve added very minimal customisations back in.

    We were hoping that the overhaul would lose the ‘past events’ issue, and it seemed that way in testing. But launching the new code, we’ve encountered the same problem again.

    We’ve wasted a lot of time working with these problems with your plugin, so I’d appreciate prompt and thorough support here.

    It may be necessary for a follow-up post so I can supply you with what you need to replicate our site and replicate the issue. However, here’s some of my debugging / notes:

    Our custom theme has one function hooked to pre_get_posts, and the only thing it’s doing is this. We were assured that this would make sure past events are never shown, but obviously it’s not working:

    if ( $query->get( 'tribe_is_past' ) ) {
    	$query->set( 'post__in', array( 0 ) );
    }

    Getting into WP_Query, when I dump the request just before it’s run, using the posts_request hook, the SQL looks OK except – to my eye, and given the issue we’re looking at – that the meta_key for _EventEndDate is specified, but the meta key for _EventStartDate is NOT specified. Maybe your engineers could make something of that? If not let me know and we can progress with getting you replicating the issue to fix it.

    SELECT SQL_CALC_FOUND_ROWS DISTINCT wp_posts.*,
                                        MIN(wp_postmeta.meta_value) AS EventStartDate,
                                        MIN(tribe_event_end_date.meta_value) AS EventEndDate
    FROM wp_posts
    INNER JOIN wp_postmeta ON (wp_posts.ID = wp_postmeta.post_id)
    LEFT JOIN wp_postmeta AS tribe_event_end_date ON (wp_posts.ID = tribe_event_end_date.post_id AND tribe_event_end_date.meta_key = '_EventEndDate')
    WHERE 1=1
      AND ((wp_postmeta.meta_key = '_yh_venue_area'
            AND wp_postmeta.meta_value = '38'))
      AND wp_posts.post_type = 'tribe_events'
      AND (wp_posts.post_status = 'publish'
           OR wp_posts.post_status = 'tribe-ea-success'
           OR wp_posts.post_status = 'tribe-ea-failed'
           OR wp_posts.post_status = 'tribe-ea-schedule'
           OR wp_posts.post_status = 'tribe-ea-pending'
           OR wp_posts.post_status = 'tribe-ea-draft'
           OR wp_posts.post_status = 'private')
      AND (wp_postmeta.meta_value >= '2017-12-16 11:31:00'
           OR (wp_postmeta.meta_value <= '2017-12-16 11:31:00'
               AND tribe_event_end_date.meta_value >= '2017-12-16 11:31:00'))
    GROUP BY wp_posts.ID
    ORDER BY EventStartDate ASC,
             wp_posts.post_date ASC
    LIMIT 0, 10
    Posts: 14 Topics: 4
    | Permalink

    I think I’ve managed to fix this. It looks like there were changes in how custom filters should handle altering the query. I’ve followed the example of the most recent source and filtering now no longer shows past events.

    Posts: 9778 Topics: 1
    | Permalink

    Good evening Sarah and welcome back!

    Thank you for reaching out to us and sharing your findings for everybody’s benefit.
    I would love to help you with this topic.

    First of all, major kudos for updating your code and being able to tackle this one!

    You are absolutely right. Our code is subject to enhancements and change.
    The specific part of the code you were working with is no exception.

    As you can imagine, as functions get deprecated, adjustments to your custom templates will most likely need to be performed. Unless you “freeze” you the Events Calendar versions of course.

    With that in mind, just to set expectations in the future, the scope of our support is mostly to get our customers started on the right track and to help them in case of issues.

    We unfortunately do not provide complete support for customization.

    You are welcome back in our support forums any time 🙂

    For now, I am going to close this thread.

    Have a great week!

    Geoff B.

    Posts: 7
    | Permalink

    Hey there! This thread has been pretty quiet for the last three weeks, so we’re going to go ahead and close it to avoid confusion with other topics. If you’re still looking for help with this, please do open a new thread, reference this one and we’d be more than happy to continue the conversation over there.

    Thanks so much!
    The Events Calendar Support Team

    | Permalink

The topic ‘filtering shows past events’ is closed to new replies.