get_posts() only returns upcoming events

Home Forums Calendar Products Events Calendar PRO get_posts() only returns upcoming events

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1019040
    Cully
    Participant

    I’m trying to get certain events using get_posts(). The problem is that Events Calendar has a pre_get_posts filter that adds a WHERE clause to only get future events. So if the post I’m querying for is in the past, it won’t get returned by get_posts(). How do I tell Events Calendar not to mess with my query?

    FYI, I’m not concerned with whether they are past or future, so I don’t want to use tribe_get_posts(). Also, why doesn’t tribe_get_posts have an option to get ALL events, instead of just upcoming or past? Yes, I know you can use custom, but you have to provide a start and end date, and yes you could provide a date very far in the past, but that seems hacky to me.

    #1019174
    Brook
    Participant

    Howdy Cully,

    I appreciate your sharing your background knowledge of this.

    How our queries run is a bit of hacky relic from the early days of the plugin. 🙁 I am sad to see that it is interfering with your get_posts() query, but I am not totally shocked that it is. Would you mind sharing the code you are running that is being interfered with?

    We would love to clean up our queries. But there is a lot of custom sites and themes out there that are currently relying on the current setup, and so we haven’t taken the plunge yet to clean things up and simultaneously interfere with legacy support.

    Aside from waiting on us to fix this (and your example code will help) you have have two options:

    1. Run a priority 52 or greater action on pre_get_posts, correcting the where clause.
    2. Using tribe_get_events() with ‘custom’ and a date in the distant past or future.

    Does that make sense?

    Just so you know, we have been making huge strides lately cleaning up legacy code, making it testable and so forth. It’s something we are taking seriously and working to do in an organized fashion. We have a lot of new devs to the team, some of whom have made this their sole focus.

    Cheers!

    – Brook

    #1019187
    Cully
    Participant

    Yeah, that’s actually a super great response 🙂 Thanks for being so upfront about where you all are at. For some reason I’ve had quite a few customer service experiences in the past few days, and it’s refreshing to hear some honesty.

    I ended up fixing the problem using tribe_get_events(), but didn’t have to provide a start/end date for some reason. I basically just sent the same parameters I was sending to get_posts() to tribe_get_events(), without setting “eventDisplay”, and it worked. Not sure why, but I don’t really care at this point 🙂

    #1019508
    Brook
    Participant

    Hah! I wish that things worked magically all of the time. eventDisplay has made fools of us all, but I thought I knew all of its quirks at this point.

    You are very welcome sir. I appreciate your understanding as well.

    Since this is marker resolved I am going to archive it. Ta!

    • Brook
Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘get_posts() only returns upcoming events’ is closed to new replies.