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