Posted: June 14, 2020 at 1:17 pm
Hello! I am trying to get a set of events that are in a category and not expired but my query keeps on showing me expired events. This is the get_posts() filters I am sending. Is this the correct syntax for filtering out expired events?
Everything else here seems to be working. I get a set of event posts in that category. Thanks in advance for any assistance! |
|
I found this thread,, but it seems like a lot of extra code on every search just to tune one search… https://eventespresso.com/topic/expired-events-still-show-up-in-global-search-results-2/ It suggests adding a pre_get_posts filter and detecting something about the query. Well, if I went this route…. what would I detect about the query I want to modify to show_expired = false? This example is detecting whether it is a search query or not. My query is just a custom query. Thanks! |
|
Hi Daniel, Is there a specific reason you are using IMO this is much easier with the model system.
It’s not ‘tuning’ one search, its excluding expired EE events from any ‘main query’ search. May I ask how else you would prefer to exclude expired EE events from the standard WP search? We have to check its a search query and then include the additional SQL within that query to exclude EE events.
You would need to check the query relates to EE events and the show_expired attribute was set, however again, the model system makes this much easier. |
|
And of course, I forgot to include the category in the example, I’ve updated my above reply to include the term set on the event(s). |
|
The support post ‘EE show_expired syntax for get_posts’ is closed to new replies.
Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.