Skip Navigation

[Resolved] Search by postrelationships

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

Author
Posts
#2639473

Hi!

I am trying to create a search using a relationship. So I tried to follow the steps:

1. Edit the page that holds your View with a custom search.
2. In the View editing area, click the Add Search Field button.
3. In the dropdown that appears select the Post relationship or repeatable field groups owner option.
4. In the right sidebar, expand the Field Settings section and use the dropdown menu to select the relationship you want to add a filter for.

When I get in the 4th step, I can´t find the relationship to select. There is a message: "There are not futher ancestors defined". What should I do?

How can I add a relationship as a custom field to be included in more than one post types?

Thank you.

#2639661

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi there

Could you please clarify:

1. what relationship do you refer to? (What kind of relationship, e.g. one-to-many, many-to-many, and which post types are connected in the relationship.)

2. the View you are trying to add a relationship search filter for, what does the View display? (What post type does the View query?)

#2639807

Hi!

It is a many-to-many relationship.

I have 2 post types related: "Counties" And "Parks". Some Parks are located in two or more Counties and some Counties have more than one Park. That is why I choose a many-to-many relationship.

I also have a third post type: Facilities. I would like that the user when searching for facilities in a park area could select the counties related to the park individually. Park would be the parent and counties the child.

How can I add the post type "Park" as a custom field of the post type "Facilities" to show a list of all the parks in a dropdown selector and, after selecting the Park, how can I show the counties related?

Thank you.

#2640033

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

"I would like that the user when searching for facilities in a park area could select the counties related to the park individually."

I'm sorry, but I still don't understand that.

You have a M2M relationship between Counties and Parks. Understood.

You also have a post type Facilities, which is currently not related to either Counties or Parks, and the question is about how it might be.

To understand what's required, I need to know what the users are aiming to do on your site in this context.

They are searching for Parks, and they need to be able to filter by what facilities are available at the park?

Or something else? (I'm having trouble imagining what the something else is here.)

(If the users are searching for parks with certain facilities, my instinct is that facilities would be a taxonomy rather than a post type.)

#2640131

Hi!

Sorry, I wasn´t clear.

What I am trying to do is a cascading dropdown where Parks would be parents and Counties related to parks would appear as its child in a way that the user when searching for a facilitie in a Park could select "all the park" or a specific countie of the park.

But from what I read in the forum, it is not possible to build a cascading dropdown. Is there a way?

Thank you!

#2640531

Hi,

What you're trying to achieve may not be possible, directly. But I can recommend a workaround or alternate approach.

Can you please share temporary admin login details, along with the link to the Facilities search page? I'll be able to suggest the next steps, accordingly.

Note: Your next reply will be private and making a complete backup copy is recommended before sharing the access details.

regards,
Waqar

#2642213

Thank you for sharing the access details.

Reviewing the existing setup, here is the closest possible option that I was able to deploy.

1. I've created a 'many-to-many' relationship between the 'Facilities' and the 'Parnas Directories' post types.

2. Next, in the archive for the 'Facilities search', I've included the relationship search filter, which consists of two levels:
- Facilities Parnas Directories
- Parnas Directories Hotels
( screenshot: hidden link )

On the front end, you can see that the two interlinked forms are showing for these relationships.
( screenshot: hidden link )

I hope this helps and please let me know if you need further assistance.