Exclude Past Events from Query

Home Forums Calendar Products Events Calendar PRO Exclude Past Events from Query

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #28266
    Jason
    Participant

    I’m having trouble preventing past events from showing in certain areas of my site. I’ve set ‘eventDisplay’ => ‘upcoming’ but past events are still coming through.

    Here is my full query:
    $my_query = new WP_Query( array(
    ‘post_type’ => ‘tribe_events’,
    ‘post__in’ => get_option( ‘sticky_posts’ ),
    ‘eventDisplay’ => ‘upcoming’,
    ‘posts_per_page’ => 3
    ) );

    I’m using the Sticky Custom Post Types plugin to pull these posts into a slideshow, per Jonah’s suggestion in a support thread, which is why I have get_option(‘sticky_posts’) included. I’ve tested this with all other plugins except for Sticky Custom Post Types deactivated and still encountered the issue.

    Any help in resolving this issue would be greatly appreciated.

    Thanks,

    Jason

    #28271
    Sandro
    Participant

    I’ve similar problem, upcoming filter for me is not working. I’ve past events showing up in widget with code similar to yours and also in list.php

    https://theeventscalendar.com/support/forums/topic/single-day-view-displaying-past-day-events/

    There is a bug I think.

    #28281
    Barry
    Member

    Hi Jason, I’m not sure that Tribe-specific conditions such as eventDisplay are respected in a new WP_Query.

    #28302
    Jason
    Participant

    Is there another method I should be using that will respect it? I’m trying to run multiple loops and output sticky posts in one div and the rest in another div that can be shown jQuery.

    Here is the code for both loops that I’m using on my list.php file: http://pastebin.com/zrK1RK4u

    I’ve noticed is that when an event isn’t sticky, it doesn’t appear in the second loop. Only the first loop has the problem.

    #28311
    Barry
    Member

    Generally we recommend using tribe_get_events() if you need to run an event-related query, as that helps to ensure that the query is processed by The Events Calendar (otherwise non-standard keys like eventDisplay will most likely be ignored).

Viewing 5 posts - 1 through 5 (of 5 total)
  • The topic ‘Exclude Past Events from Query’ is closed to new replies.