This technical implementation covers:
- CPT & custom fields setup
- Parent/child hierarchy
- SAP directory page
- SAP state/city dynamic template setup w/ conditional logic for parent/child
- Dynamic data
- Query looping for parent/child
- WP Grid Builder map facet integration
- WP Grid Builder ajax search facet integration
NOTE:
You would rarely need to query just the states on the main directory page. This would only be the case if you were working with a business that services LOTS of different states/countries. In most cases, go straight to querying the cities. BUT…
The query adjustment to only query cities and not states via parent/child relationship breaks the WP Grid Builder facets in Bricks because it requires a custom query and I haven’t found a way around this.
As soon as I find a good solution I’ll post an update. For now, if you’re going straight to querying cities, I would query all service areas (both states and cities) and then manually exclude the states (this is easy to do in Bricks’ query loop) by selecting them in the exclusion dropdown. It’s a little chumpy, but it works just fine assuming that you’re not going to have many states to manage.
Also remember that if you’re not going to be expanding outside of a state or country, there’s no reason to have the state/country parent level in the first place.