Hello,
I use hierarchical taxonomy:
Tax_1 ==> Tax_11
Tax_1 ==> Tax_12
Tax_1 ==> Tax_13
...
Tax_2 ==> Tax_21
Tax_2 ==> Tax_22
Tax_2 ==> Tax_23
...
Only Child Taxonomies (Tax_ij) are assigned to my CPTs. I need to access the Parent Taxonomy (Tax_k) in 2 situations:
1 / When I am in my CPT
2 / When I am in the archive of my CPT: for each item
There is no default Shortcode, and I have to add one, but despite my research I can't...
The shortcode must take as input the name (or the slug) of the child taxonomy.
It has to returned me :
a) the name of the parent taxonomy
b) a link to the parent taxonomy.
Can you help me ?
Regards
Something like this should get you started
https://www.tukutoi.com/doc/shortcode-to-return-the-parent-term-id-of-a-given-term/
It takes the term ID and taxonomy name as input and returns the parent term ID as output.
Of course you can change both input and output logic (you’d have to use different php though, referring to the WordPress API and Term Object)
Hope it helps!
Hello, Toolset does not provide a built-in shortcode or API function to achieve exactly what you are describing, so a custom code solution is necessary. I like the solution presented by smileBeda to return the parent term ID with a custom shortcode. If you'd like additional assistance, please provide the custom code you have implemented, let me know how you'd like to change the functionality, and I will let you know what we can do to help here in the forums. Since this is mostly pure WordPress programming unrelated to Toolset's APIs, support here in the forums is somewhat limited, but I can try to guide you to other examples if you get stuck somewhere.
My issue is temporaly resolved. Thank you!