Posted: May 11, 2015 at 9:01 am
|
Hi there, I am trying to set up a custom search which lists events but can’t get it to filter by venue. Should I be able to do this? `$search_args = array( Thanks in advance. |
|
Hi, Looking at the code here /wp-content/plugins/event-espresso-core-reg/shortcodes/espresso_events/EES_Espresso_Events.shortcode.php and on the http://code.eventespresso.com/class-EE_Event_List_Query.html it does not look like you can just drop in the venue aspect. I think it’s probably best to use the loop and then on each event check for venues, so for example add this into the loop:
Obviously, that will dump out any related venues for the event, but you can get the appropriate data from it. Then you can use the get method to pull out the data. For example you could use:
Which will echo out the venue name. Does that help? |
|
Hi Dean, Thanks for your quick reply, I am looking to only show events for a particular venue though (as well as other search criteria) which doing it this way will be very slow no? |
|
Hi, It will be slower, but whether it is noticeably slower is hard to say without benchmark testing. However, there really isn’t another way: the event post type doesn’t hold the venue data, nor does the post meta. Right now the only way I can see it working would be to get the events and filter them by venue as discussed above. There is an SQL join with the venues in /wp-content/plugins/event-espresso-core-reg/core/helpers/EEH_Event_Query.helper.php but this seems to only be applicable if the event query uses the order_by parameter. |
|
Hi Dean, So that would only work if the venues are ordered by venue? I am guessing I could do it with a custom SQL query, I don’t suppose you have any SQL examples for joining the event and venue tables? Thanks Damian |
|
Hi,
Pretty much yeah, it just allows the events to be ordered by venue. Well, my SQL-fu is somewhat limited but I came across this in /wp-content/plugins/event-espresso-core-reg/core/db_models/EEM_Base.model.php (comments)
I haven’t tested it but it looks like a good starting point. I do know that you will need to use the *_esp_event_venue (* = table prefix) table to join the event post and venue posts together. |
The support post ‘Filtering by venue, custom search’ 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.