Skip Navigation

[Resolved] Question on the best way to organize a CPT by State, County, and City.

This support ticket is created 3 years, 6 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.

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 1 reply, has 2 voices.

Last updated by Christian Cox 3 years, 6 months ago.

Assisted by: Christian Cox.

Author
Posts
#2063041

A few years ago I created a resource website for people needing assistance (food, medical, etc) intended to help those in need. At the time I had created it with only a single county and the cities within that county in mind in which I used a "City" field to do that.

The website is now needing to be used in multiple States, Counties, and Cities now, and I am looking for the best possible way using Toolset to organize it.

I did find this post in which the person was instructed on how to set up States, Counties, and Cities as CPT's with relationships setup.
https://toolset.com/forums/topic/best-way-to-organize-content-by-location-state-county-city-across-post-types/

My question is what are the pro's of doing it this way instead of say... Custom Taxonomies? Taxonomies can be hierarchal right out of the box. Does it have something to do with Custom Fields? I know I have had issues in the past trying to search with or display custom taxonomy fields so this could make sense...

Any insight on why yall chose that way over the other would be greatly appreciated.

Another question, using the CPT with relationship method.. If I have a CRED front-end post form for people to setup their own resource, how do they select the States, Counties, and Cities their resource services? Does Cred Frontend Post Forms allow you to set CPT Relationships for a new resource post submission?

Also, using the CPT with relationship method, how would you populate the states/counties/cities? is it only manual (aka I have to go in and create each state, city, etc, or is there a way to import them?

Thanks for any and all advice you can give me in the revamp of this website to better help people!

#2063271

My question is what are the pro's of doing it this way instead of say... Custom Taxonomies?...Does it have something to do with Custom Fields?
I can think of a few pros:
- As custom post types, States, Counties, and Cities get their own dedicated post URLs as well as automatic archives. Taxonomy terms only get archives.
- As custom post types, you can create custom search Views to find States, Counties, and Cities, filtered by post relationships, custom fields, text search, and/or taxonomy terms. You cannot use Views to create custom searches to find or filter taxonomy terms.
- In the case of hierarchical One-to-Many (O2M) relationships, you can create post relationship filters for each ancestor level. For example, in a custom search View of Cities, if State is a parent of County and County is a parent of City, and each of those post relationships is a O2M relationship, you can create a staggered search filter where the User selects first a State, then a County from that State, to filter a list of City posts. There is no such hierarchical staggered filtering system build into Views for taxonomy term filters.
- Importing posts and importing terms are a bit different in WordPress. You can import posts with custom field values from an XML or CSV document. I'm not sure if you can easily import taxonomy terms and their field values like this. Normally when you import posts, you can import the terms associated with those posts in the same import file. But I'm not sure about importing terms and term fields independently of their posts, I've never tried it.

Does Cred Frontend Post Forms allow you to set CPT Relationships for a new resource post submission?
In some cases yes, in others no. When you use Forms to create or edit the child post in a one-to-many post relationship, Forms will provide a select field where the User can choose one parent post in that post relationship. Other ancestors in hierarchical O2M relationships are inferred based on the parent the User selects - there is no grandparent or great-grandparent select field in a child post Form, for example, only a parent field. Many-to-many relationships are managed in completely separate Relationship Forms.

Also, using the CPT with relationship method, how would you populate the states/counties/cities? is it only manual (aka I have to go in and create each state, city, etc, or is there a way to import them?
You could import those posts from a CSV document or using WordPress's standard XML import tool.
https://toolset.com/course-lesson/how-to-import-content-into-wordpress-using-csv/