Posted: June 28, 2023 at 6:03 am
I have an event listing which is an archive page https://aerosol-soc.com/events/ showing upcoming events. There is an event from 26-30 June that should be at the top, but is listed lower down, after 14th Nov, but before 16th Nov events. |
|
Hi there, What are you using to query those events? It doesn’t look like a standard WP archive loop. |
|
Hi Tony, It is a archive-espresso_events.php template file in the root of the theme with Thanks |
|
But there are multiple events__listing containers so there’s something more than just a single loop, right?
Sure but within that snippet is a check to make sure it’s only running on the main query:
So is the above the main query or something custom? |
|
Thanks Tony. There are two events__listing containers, one is the main query, it starts: The second one sets out some $args, and then:
|
|
Hmmm, ok. If you install something to check the query on the page, does it show the custom order_by in use on that snippet? For example, using Query Monitor or Debug Bar and inspecting the main query run on that page? I suspect that code isn’t hooking into that query. |
|
Thank Tony. I installed Query Monitor, and it’s showing a 1066 error (Not unique table/alias: ‘tl_esp_datetime’) due to FacetWP. If I disable FacetWP the order is correct, but I have to disable Query Monitor shows me that this is the database query with the error, but I have no idea how to edit it:
So I guess FacetWP is the culprit, and perhaps I should raise it with them. I need to prevent FacetWP interfering with this query, since FacetWP isn’t even used on this page! Thanks for your help. |
|
It looks like those filters are being applied to the query multiple times:
3 times?
2 times?
3 times? —
It’s not? But above you said it is:
That isn’t mean trying to be nit picky, I’m trying to work out if there is a way to exclude those filters without breaking your page’s functionality. |
|
Yes, multiple times, but I have no idea how to change that. However, I fixed it with help from FacetWP support and this snippet they sent for another event plugin https://gist.facetwp.com/gist/gist-ea65868cf1d314990872f85f6dfc90f1/ Sorry, when I said FacetWP wasn’t being used on the page, I meant there was no filtering of events on this page (which is what FacetWP does). Thanks again for your help. |
|
Oh, nice. So you just changed the above to check for the espresso_events post type?
Using that snippet stops the filter being run multiple times? |
|
Yes, that’s right. It works well, no database error, and events are ordered correctly. Thanks again for your help. |
|
Ah awesome, I’m glad you found a solution 🙂 |
|
The support post ‘Sorting events by date’ 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.