Skip Navigation

[Resolved] Struggling setting up hierarchy between custom fields and taxonomies

This support ticket is created 2 years, 8 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)

Author
Posts
#2113579

Tell us what you are trying to do? My site will be for searching for trades such as Carpenters, Drywallers, Electricians, Flooring Companies, Landscaping companies, real estate agents (you get the idea ) Do I use taxonomies to create a separate state for every trade? So carpenter would have 50 taxonomies (one for each state), and so on with the other trades. Or should the state just be added in the custom fields. Ultimately my goals is for trades will be searched by state, city, and zip codes.

Is there any documentation that you are following?

Is there a similar example that we can see?

What is the link to your site? hidden link

#2113599

Hello, ultimately it is up to you how you want to structure the data. A few things you should consider are outlined in our documentation here:
https://toolset.com/course-lesson/using-custom-fields-vs-taxonomy/

Some other information to consider:
- Taxonomy-based searches are generally faster than custom field-based searches because of how WordPress's database is set up. If you have a lot of content to search, and you want to create many different search filters, taxonomy filters are usually preferred over custom field filters for this reason.
- Unlike custom fields, taxonomies cannot be applied to Users, Repeatable Field Groups (RFGs), or Many-to-Many (M2M) Post Relationships.
- It is usually not a good idea to create taxonomy terms with numeric slugs - like 5-digit zip codes, for example. This can cause problems where term IDs and slugs are both numeric, leading to ambiguous queries. In those cases it's better to add a letter or letters to the beginning of the slug, like "zip12345" instead of "12345"
- States might not change often, but you might consider how cities and zip codes will be managed during post data entry in wp-admin as taxonomy terms vs. as custom field options. New taxonomy terms can be added easily right in the post editor screen, for example. New options for a "select" custom field cannot be added directly in the post editor screen. You would have to edit the custom field group, then reload the post editor screen to select the new option in a custom field. There are other subtle differences, so experimenting with both is probably the best way to determine which works best for your workflow.

Do I use taxonomies to create a separate state for every trade?
It's up to you whether you use a taxonomy or a custom field to represent States. If you decide to use a taxonomy, I would create one "State" taxonomy and create one term corresponding to each state:
- Alabama
- Alaska
- Arkansas
...etc.
I would not create trade-specific terms like:
- Alabama (Drywall)
- Alabama (Plumbing)
- Alabama (Electrical)
...etc.
Configure the State taxonomy to be used in multiple custom post types and apply the same state term to posts in all those post types. This will enable you to have custom search Views querying multiple post types using the same taxonomy term filters. Trade-specific terms like Alabama (Drywall) and Alabama (Plumbing) will not allow searching for Drywallers and Plumbers with the same search filters.

#2114467

Thank you Christian for your help. I am not sure what you meant by "I would create one "State" taxonomy and create one term corresponding to each state" I do not know what you mean by term.

#2114469

Also when you add a taxonomy it prompts you to enter a plural name. Arizonas?

#2114597
Screen Shot 2021-07-14 at 2.26.47 PM.png
Screen Shot 2021-07-14 at 2.40.18 PM.png
Screen Shot 2021-07-14 at 2.44.43 PM.png

I am not sure what you meant by "I would create one "State" taxonomy and create one term corresponding to each state" I do not know what you mean by term.
A taxonomy is a group of terms. You can create multiple custom taxonomies, and each taxonomy can include multiple terms. A custom taxonomy "Film Genres" might have terms like "Comedy", "Drama", "Action", "Science Fiction", and so on. A custom taxonomy "States" might have terms like "Alabama", "Alaska", "Arkansas", and so on.
See the WordPress article here:
https://wordpress.org/support/article/taxonomies/

I am attaching screenshots illustrating differences between taxonomies and terms. I have created a custom taxonomy "Book Taxes" and applied it to a custom post type "Books". If you go to wp-admin > Books > Book Taxes as in the first screenshot, you can see a list of the existing terms in the Book Taxes taxonomy. I have another taxonomy "Flat taxes" applied to the Books post type, as well, but you would manage those terms in Books > Flat taxes instead of Books > Book Taxes. When you create or edit a Book post, you can manage the Book Taxes terms associated with that post.

Also when you add a taxonomy it prompts you to enter a plural name. Arizonas?
The taxonomy I'm referring to should be States / State. The term Arizona can then be added when you manage posts, or when you go to wp-admin > Trades > States.

#2116683
Template.JPG
Post-form.JPG
Form.JPG

Once again, thank you for your support Christian. I am switching topics, can you please tell me if me if I have properly created a template, post form, and a custom fields form so they properly feed into each other.

New threads created by Christian Cox and linked to this one are listed below:

https://toolset.com/forums/topic/confirm-setup-of-template-post-form-and-custom-fields/

#2118047

Sure, our support policy is to address one issue per ticket, so I'll split off a new ticket so we can discuss your implementation in more detail.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.