Skip Navigation

[Resolved] Creating Business Category Taxonomy, with a sub-category. Display on front

This thread is resolved. Here is a description of the problem and solution.

Problem: I would like to highlight top-level hierarchical taxonomy terms in a multiselect field on a Form.

Solution: You can apply custom CSS that targets selectors using the data-parent attribute.

select[name="business-category[]"] option[data-parent="-1"] {
  font-weight: bold;
}
This support ticket is created 6 years 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

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
#1136306
screencapture-membership-eyeprosper-new-member-profile-amalie-media-llc-2018-10-28-20_36_20.png

Tell us what you are trying to do?

I am replicating an existing website. I have created custom fields, forms and views and now realize the Business Category is not set-up in a way it will work, as I had hoped, so back to the drawing board.

A new member when creating their member profile will select a business category from a drop-down (form), then a sub-category of that main category. I currently have one select drop-down, but it doesn't do multi-select. These categories, once selected will also be dynamic as a Post Term Taxonomy on my Elementor Template for the front-end member profile page, as well as being searchable by category, resulting in a category archive page. So I need to get this right.

Sample shows the member profile page I'm working on that I had some other questions in a support ticket.

Is there any documentation that you are following?

Is there a similar example that we can see? Here is the form, with no formatting. hidden link

What is the link to your site? hidden link

#1136940
Screen Shot 2018-10-30 at 12.28.58 PM.png

A new member when creating their member profile will select a business category from a drop-down (form), then a sub-category of that main category. I currently have one select drop-down, but it doesn't do multi-select.
Hi, I'm not sure I understand the problem. When I visit this page, I can see a multi-select field where I can select multiple Business Categories by holding down Control (or Command on a Mac): hidden link
I'm attaching a screenshot here showing multiple selections. Are you saying that this multi-select field isn't saving the selected Business Category term(s) as expected when the Form is submitted? Or are you saying it saves the terms correctly but then you can't display that information for the new profile on the frontend of the site? Or is there something else I didn't understand?

#1136949

HI Christian,

I don't think it's clear to the user since they all appear in one list. Maybe it's simple as making the category bold, or another color and the sub-category have a dash before or more space on the left so there is hierarchy? Can the dropdown be styled with CSS? or Is there a way to select the category, then in a second drop-down select the sub-category for the selected category?

#1136992

Can the dropdown be styled with CSS?
Yes, you can apply your own custom CSS in the Form editor screen. For example this turns the top-level categories bold:

select[name="business-category[]"] option[data-parent="-1"] {
  font-weight: bold;
}

or Is there a way to select the category, then in a second drop-down select the sub-category for the selected category?
There's not a simple way to do this built into Views. It would require a significant amount of custom code with the Forms API, generic fields and Forms Conditionals. The general idea is you create one generic select field that holds all the top-level categories, then you create an additional generic select field for each of those top-level categories. Each of those fields holds all the subcategories of a single top-level category. Then you use Forms conditional groups to show and hide the subcategory generic fields based on the selected main category. You can use Views to define the options for each generic field.

When you're placing these input fields on an "Edit Post" Form, it's more complicated because you must be able to set the correct selections when the Form loads. Next you need to use the Forms API to capture the value of the selected categories and subcategories using PHP, and save them along with the post. So the simple approach is to use CSS if possible to style the multiselect input field, the more complex approach is to set up a generic field system in the Form.

#1139518

My issue is resolved now. Thank you!

With you help I was able to target the correct area and update the CSS on the dropdown to have the business category bold and the sub category have padding on the left and not bold. There is now a distinct difference between the two.

Thank you for your help.

Laurie