Support Forums

Hey there, it looks like you've been redirected from designsandcode.com - as you can see we have a new home - read more

Looking for support? You can access the support system via your account.

Forums Forums Search & Filter Pro Filtering based on data in related custom post types

Viewing 6 posts - 1 through 6 (of 6 total)
  • Bas Mensonides
    #105335

    [split by @trevorsf from https://support.searchandfilter.com/forums/topic/filtering-based-on-data-in-related-custom-post-types/ ]

    The way I read it, the problem mentioned by Brooke is exactly my problem. Did you manage to find a solution to this problem, Trevor?

    Thanks in advance!

    Trevor Moderator
    #105363
    This reply has been marked as private.
    Bas Mensonides
    #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 Moderator
    #105400

    The form is based on a CPT called Events.

    In the Events is an ACF relational field called Venue, which is linked to a CPT called Venue 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.

    Bas Mensonides
    #105735

    That is correct 🙁
    Are there plans to include this in the future?

    Trevor Moderator
    #105738

    I 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.

Viewing 6 posts - 1 through 6 (of 6 total)

The topic ‘Filtering based on data in related custom post types’ is closed to new replies.