Forums › Forums › Search & Filter Pro › Filtering based on data in related custom post types
- This topic has 5 replies, 2 voices, and was last updated 8 years, 5 months ago by
Trevor.
-
Anonymous(Private) April 28, 2017 at 10:38 am #105386
Hi Trevor, thanks for the quick reply!
Unfortunately, at this moment it is not possible for me to show a live URL. I will describe my problem to the best of my understanding.
I have 2 custom post types: venues and events.
An event is related to a venue by the ACF “relational – post object”.
This is quite usefull for me because when adding an event, the poster doesn’t have to supply all the venue details, because those are related. Now this works very good, and on the single page of an event all the venue details are being pulled.Now for the search form.
What I want is a search form that searches the events based on the field “event type” AND based on the location of the venue, say country and city.
Country and city are both fields that are linked to the venue and indirectly to the event.
I have created a search for which searches in the post types events and venues. I have added 3 search fields (post meta): event type, country and city.The event type works as expected. Country and city do not. When I select an event type first, the country and city dropdown menu’s are empty. Which is not correct. The other way arount, when I select a country first the results are empty. Even though I know that country has events.
Hope this is a clear enough description. I know that a workaround can be to force the poster of an event to add the country and city, so that those are related to the event instead of the venue. This is not an ideal situation since it allows errors and is less efficient.
Trevor(Private) April 28, 2017 at 11:58 am #105400The form is based on a CPT called
Events
.In the Events is an ACF relational field called
Venue
, which is linked to a CPT calledVenue
and THAT has the Country and City fields?If I have this correct, then, NO, our plugin cannot drill that far down to retrieve those fields.
Trevor(Private) May 1, 2017 at 10:39 am #105738I am not aware of any. The problem is, drilling down into such relationships can end up being circular, and that becomes a programming black hole. The same issue applies to Repeater Fields. Each time you did such a link, this would have to be cached, and the cache size would increase exponentially.
I did try this in a different plugin and it took the site down. It was a sandbox test server, so no long term harm done. I did build safeguards in to that plugin to stop this endless looping, but the whole thing became too difficult to manage, so I removed support for this type of feature. Whilst Ross is the developer of Search and Filter, and not me, I expect he found the same problem.
From a lay point of view, what you ask for sounds sensible and logical. From a programming point of view, it can be a nightmare.
-
AuthorPosts