Posted: September 16, 2016 at 2:22 pm
|
Hello EE team. I managed to create a custom taxonomy with the following code on functions.php, and created a simple taxonomy-ciudad.php on my template to show my posts. The problem is, I have no idea how to filter the query for my taxonomy template, so it gets only active events, and order them by start date. Normally I’d use a function on my template’s functions.php with pre_get_post and order by meta_values, but EE4 creates the dates on its own db table, not on postmeta. So offcourse something like this won’t work:
Even though I really want to use the taxonomy-ciudad.php template, I also tried to use a custom query like the one here: https://gist.github.com/idliketofly/d754f45c0861023d7529 but I didn’t know how to make it work with the custom taxonomy. I currently use Event Espresso 4.9.11.p on WordPress 4.6.1. I’d appreciate any help.
|
Just because event date times aren’t stored as meta values, that doesn’t mean you can’t order by those dates, or filter out expired events. For example you can filter out expired events from your query with:
then before the loop:
There are a few other examples in the WordPress codex: https://codex.wordpress.org/Plugin_API/Filter_Reference/posts_where |
|
|
Thanks for your help. I think I’m starting to get somewhere but I still can’t get it to work. I tried putting the filters on taxonomy-ciudad.php, before the loop and removing them after, but as you can see here they work only on functions.php and didn’t do anything at all. I created something like this but when I use any of the 3 filters the query returns no results. This code is on functions.php on my template. Do you know if I’m missing anything? I tried only the first one with your ‘EEM_Datetime::instance()->table()’ but it didn’t work either.
|
September 23, 2016 at 12:14 pm Yeah that’s not going to work, here’s something that you can try instead: https://gist.github.com/joshfeck/26e0e27bb9c9fa7ed7159c0c6c9704ea |
|
The support post ‘Order custom taxonomy template by start date and do not show expired’ 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.