Skip Navigation

[Resolved] Parent Taxonomy Shortcode

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

Last updated by fredericR-2 2 years, 9 months ago.

Assisted by: Christian Cox.

Author
Posts
#2117917

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

#2118065

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!

#2118115

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.

#2120817

My issue is temporaly resolved. Thank you!

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