Problem: I am using the Real Estate reference site as an example. When creating a House post, I would like to select a State, then select a City from a list of Cities in that State.
Solution:
In wp-admin, there's no built-in way to do this. There is no "grandparent" post selection in post relationships, only parent selection. You could add the state abbreviation to each duplicate city post title:
City - "Kansas City, KS"
City - "Kansas City, MO"
In Forms, there is a more complex solution:
- Create a generic select field that includes an option for each State. The value of each option should be the State post ID. You can use a View of States to create the options for the generic field.
- Next create one generic select field for each State. Add options for each City in that State. You can use a View of Cities filtered by post relationship to create the options for the generic fields.
- Use Conditional Field Groups to show and hide the City select fields based on the selected State.
- Then capture the selected City post ID using the Forms API, and use the Post Relationships API to link the House and the City.
Relevant Documentation:
https://toolset.com/documentation/user-guides/inserting-generic-fields-into-forms/
https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data
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 |
---|---|---|---|---|---|---|
8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | - | - |
13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | - | - |
Supporter timezone: America/New_York (GMT-04:00)
This topic contains 5 replies, has 2 voices.
Last updated by 6 years ago.
Assisted by: Christian Cox.