Skip Navigation

[Resolved] Guidance on how to setup Location relationships

This support ticket is created 3 years, 2 months ago. There's a good chance that you are reading advice that it now obsolete.

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.

Author
Posts
#1287581
real_estate_doc_1-805x468.png
front-end-search-1024x653.png

What is the best way to add Location information to a custom post type?

Currently, my custom post type "Listing" includes a custom field type of ADDRESS. The ADDRESS field contains the complete address including City, State, Zip, Country.

But I would like to be able to create a dropdown filter to search by State & City using the "Filter by post relationship"

Do I need to create custom post types "State" & "City"?

How did you accomplish this on the real estate site in the following documentation:
https://toolset.com/learn/how-to-build-a-real-estate-website-on-wordpress/

It's also vaguely covered here on your documentation page:
https://toolset.com/documentation/post-relationships/how-to-display-related-posts-with-toolset/how-to-filter-posts-by-their-ancestors/

What is the link to your site?
hidden link

#1287653

In the Real Estate site, the "State" and "City" information are managed separately from the address custom field information. The information returned from the geolocation API is not split apart into separate components, like city and state. In the Real Estate site, City and State are both custom post types, and there is a one-to-many relationship between States and Cities. There is also a one-to-many relationship between Houses and Cities. So this creates a chained one-to-many post relationship, like Grandparent > Parent > Child. This is how the State and City filters are implemented in the House search View. https://toolset.com/documentation/post-relationships/how-to-display-related-posts-with-toolset/how-to-filter-posts-by-their-ancestors/

If you create a free account at https://discover-wp.com, you will be able to create a sandbox Real Estate site to see how it's all put together.