Skip Navigation

[Resolved] Hierarchical taxonomies

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

Our next available supporter will start replying to tickets in about 1.28 hours from now. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 8 replies, has 2 voices.

Last updated by Shane 6 years, 3 months ago.

Assisted by: Shane.

Author
Posts
#1088387

Pat

Hello,

I have a postype "Objet" that uses 3 types of custom taxonomies :
- 2 of them are flat and there is no issue
- The 3rd one is hierarchical and I'm not sure on how to manage this.
This hierarchy is as follow :
- Lamps
- Bulbs
- Bayonets
- Led
I have a menu that list all first level taxonomies (ie Lamps here). I want to be able to display all postypes that are related to Lamps (Bulbs + Bayonets + Led) in a first step (then, I have created a search filter that enables to check / uncheck the different sub-taxonomies in the Views).
For achieving this, do I need to check on each post the chosen taxonomy AND the hierarchical taxonomy (ie : Bulbs + Lamps) or is there a way to display all postypes with a taxonomy that is under a hierarchical one (ie Lamps for this example)?
Regards
Pat

#1088663

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Pat,

Thank you for contacting our support forum.

You will need to check each hierarchy that the item belongs to, so even if the item is an LED item you must also check the Lamp Parent term as well for the filter to work as you intend it to.

Thanks,
Shane

#1089277

Pat

Hi Shane, Thanks for your answer.
The issue for me is that the taxonomy is defined by the user in frontent (Cred) and I'm not willing to ask them to check several taxonomies. Is there a way to check the parent taxonomy automatically when a child is checked ?

Regards
Pat

#1089500

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Pat,

Unfortunately no, something like this would need to be done using custom coding, which custom coding like this is out of the scope of our support forum.

If you have a large amount of taxonomies you will need to do an additional condition to ensure that it is checking the correct item

Thanks,
Shane

#1089568

Pat

Hi Shane,

I think this is a kind of feature that Toolset should propose as standard. How can you manage the hierarchical taxonomies if you are not able within Cred, to check in the same time, the desired taxonomy and the parent's one ?
In this case, the hierarchical is not of any help !!!
Any idea?
regards
Pat

#1089586

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Pat,

Thats because this is functioning the same on the backend. Remember that on the backend it is possible to select the child without selecting the parent.

What Toolset Forms does is to simply bring this functionality to the frontend. So wordpress itself doesn't have this feature so our Forms wouldn't as well.

What I'm thinking is that you can use the CRED hook to see which item is selected and add the parent when the form is selected. However the code will need to account or check for all the options.

So if you have 25 parent and 30 child terms. Then you need to run through all 30 child terms and check if the parent of that term is selected and if its not then you need to add it.

In hindsight is much simpler to let users know to select the parent as well.

Thanks,
Shane

#1089642

Pat

Hi Shane,

I'm OK to use Forms hook like cred_before_save_data
The issue for me is to recover the parent taxonomy from a specific one.
Can you help on this please
Thanks
Pat

#1091277

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Pat,

Take a look at the link below.
https://wordpress.stackexchange.com/questions/24794/get-the-the-top-level-parent-of-a-custom-taxonomy-term

This should be able to assist you with this.

Thanks,
Shane

#1091278

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Alternatively for a simpler method you can take a look at the link below.
https://stackoverflow.com/questions/8895197/how-can-i-get-the-id-of-parents-taxonomy-in-wordpress