im trying to list some events in a special order.
Im using a short code on a page so far, but with a custom template. [EVENT_CUSTOM_VIEW template_name="events-iw" order_by=venue_id,event_meta=>"skill",date(start_date)]
This is what im trying to do, but it doesnt work.
I should order by the venue, then by a meta_value, another meta_value, and in the end by the starting date.
I’ve found something like this for a custom query:
But i don’t know what the standard query is and how i can modify it.
Also i don’t see how i can make a hierarchy in the ordering with this custom query.
That code for a custom query is for EE3 if you were using the EE3 custom post type feature, which I’m guessing you are probably not.
The problem that you are probably running into is that this part
venue_id,event_meta=>"skill",date(start_date)
is getting passed verbatim to the SQL query. Unfortunately, the SQL DB cannot sort on the event meta, because it is stored in the DB as a serialized field. The only thing you could do would be to resort the results in PHP after they have been fetched from the DB and before they are displayed. It would be a customization of the Custom Templates, so would require hiring a developer to do it. For small jobs like that, we can do up to a couple hours (yours would probably be an hour) on support tokens. The relevant code is in plugins/espresso-custom-templates/index.php, line 39. We would need to make a copy of that function and customize it.
So one (ugly) option would be to sort by name and have a system like _1_4_2 this in the naming and cut the prefix away when showing it.
Since categories in EE3 do not have a hierarchy, there is no way to filter in different blocks, right. Like sorting by a group of categories A and then by a group of B?
That’s pretty much correct. The Custom Templates use the Event List which uses an SQL, so as Sidney said, the custom meta can’t be sorted that way.
Viewing 3 reply threads
The support post ‘orderby / sort by meta value’ 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.
Support forum for Event Espresso 3 and Event Espresso 4.