Skip Navigation

[Resolved] Display parent taxonomies of currently displaying children taxonomies

This support ticket is created 5 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 4 replies, has 2 voices.

Last updated by romanB-3 5 years, 8 months ago.

Assisted by: Christian Cox.

Author
Posts
#1224200

I have a taxonomy with hierarchical setup (Country > .. > .. > City)
Then I have a view displaying posts with a parametric search based on taxonomy.
Each post may have one or several taxonomies, but only children taxonomies.
In the parametric search, I only should see the current taxonomies AND THEIR PARENTS.
But I can only setup the view to display :
- either all taxonomies ;
- either only current taxonomies without their parents.
Thank you.

#1224563

Hi, there's nothing built into Views that will allow you to restrict taxonomy term filters this way. You can choose one of these two options in Custom Search Settings > Let me choose individual settings manually:
- Show all the options
- Show only available options for each input

Beyond that, the filter inputs can only be manipulated with custom code, and there is no JavaScript API for filters.

#1224579

In that case in seems the only way I can achieve what I want would be to force the parent and grand-parent categories of the manually checked category to be checked while submitting the cred form. Would this be possible ?
Thank you.

#1224629

We offer two APIs that might be helpful here.
1. cred_form_validate: https://toolset.com/documentation/programmer-reference/cred-api/#cred_form_validate
This API will allow you to stop the Form submission and display a text error message like "You must select all the parent terms" if necessary.

2. cred_save_data: https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data
This API will allow you to automatically check those parent terms even if the User did not select them in the Form. It's less work for the end User, but it could also be more confusing when these terms are selected automatically without being added in the Form.

#1224633

My issue is resolved now. Thank you!