Skip Navigation

[Resolved] filter using two taxonimies in the same filter

This support ticket is created 6 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)

This topic contains 3 replies, has 2 voices.

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

Assisted by: Christian Cox.

Author
Posts
#549564

Hi,
I am trying to filter a post type using two taxonomies in one filter. In this page - hidden link - there is the full list of doctors working in an hospital, in which the first search field "Filtra per servizio" is filtering the doctors by service using the taxonomy "services-taxonomy" (for example "allergology", "cardiology" etc.).
The problem is that in this websites we had to use two taxonomies for the services: the cited "services-taxonomy" and "complex-services-taxonomy", used for those services that are including other services. For example the complex service "Medical Imaging" includes the standard service "Radiography", and I need to make available both terms to my users.

I can't use two filters because my users don't know if what they're looking for is a standard or a complex service, so I need to merge these two taxonomies in one filter.

How can I do that?

Thanks,
Nicola

#549587

I see what you mean, but combining terms from two separate taxonomies into a single filter isn't something you can accomplish out-of-the-box with Toolset. It would require a significant amount of custom code that changes the way our filtering system works, and I would not be able to provide that kind of support here in the forum. I may be able to recommend another approach, if you can help me understand how your site works.

1. Can you help me understand why you chose two separate taxonomies instead of a single, hierarchical taxonomy? Do multiple complex services include the same standard service? Why is this type of taxonomy structure inappropriate:
- Medical Imaging
--- Radiology
--- Nuclear Magnetic Resonance Imaging (MRI)
--- Computed Tomography (CT scan)
- Orthopedics
--- Joint resurfacing
--- Prosthetics
--- etc...

2. How would you expect to organize the terms in this filter that includes both taxonomies?

#550372

Hi Christian,
I answer to your questions:
1) We used two different taxonomies because it's not possible to build a hierarchy since some services are located under different complex services, for example "Dental radiology" goes under "Medical imaging" and "Dentistry".

2) If possible we'd like to have the list ordered this way:
A) Mixed alphabetic:
- Allergology (service)
- Cardiology (service)
- Echography (complex service)
- Gynecology (service)
...
If not possible it will be good also:
B) Separated alphabetic:
- Complex Services
- - Echography
- - Physiotheraphy
- - ...
- Services
- - Allergology
- - Cardiololgy
- - ...

If I can add one question, in the same page the filter has a "text input" field that should let users search doctors by name or specialty (this one is inserted with a custom field), anyway the search for specialty is not working as, when I add the "search text" field there isn't the option "title body and custom fields". Relevanssi pro is installed and this field is set to be searched. Could you help me on this also? Tell me if it's better for me to open a new thread.

Thank you,
Nicola

#550394

There's really no simple way to accomplish this with separate taxonomies. The only solution I can think of would be:
- Create a checkboxes or multiselect custom taxonomy term field for standard service terms. Use the checkboxes to assign each standard service to one or more complex services. Hard-code the names and values of all the complex services as options for the checkboxes field. The value of each option would need to match the complex service slug.
- Use a View to loop over the complex service terms and a nested View that finds all the simple service terms filtered by the complex service term custom field. Use these two nested Views to build a custom multiselect input out of these options, and place it in your Filter Controls.
- Hide the standard complex service taxonomy inputs and the standard simple service taxonomy inputs in the Filter Controls using CSS.
- Write custom JavaScript that updates the simple and complex service inputs as the user changes the selections in the custom multiselect field.
- Use custom JavaScript that updates the custom multiselect field to match the selections in the hidden simple and complex service fields when a page with search results is loaded.

This is a complex solution that requires a lot of custom code, as you can see. Each of the points above is complex enough for a separate ticket. Let me know if you have questions about this approach.

anyway the search for specialty is not working as, when I add the "search text" field there isn't the option "title body and custom fields"
Hi, this sounds like a problem I won't be able to address in one or two sentences, so it's best to open a separate ticket. Thanks!

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