Skip Navigation

[Resolved] Display parent term name and link

This support ticket is created 3 years, 11 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
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

This topic contains 2 replies, has 2 voices.

Last updated by deanL 3 years, 11 months ago.

Assigned support staff: Beda.


When users are looking at child term archive page, I want to allow them to go back to parent term archive page. For eg, From "China", user can navigate to "Asia".

I used the code from this page:

But on frontend I ended up with error message:
Notice: Undefined index: taxonomy in /www/wp-content/themes/travelscams/functions.php on line 116 Notice: Trying to get property of non-object in /www/wp-content/themes/travelscams/functions.php on line 120
' type="category"]

See: hidden link

What am I missing here?


Well, it seems that code does not work, see the next reply on the same thread:

This here shows also that the code is faulty, but the user did not enable WP Debug like you, hence, he sees nothing, instead of the error.

That user was able to solve the problem with this code but I think it's not what you want.

Your request is to "get" the parent term, so to put it as a link to the current (child) archive page.
You cannot do that in Toolset.

I mean, you could set up Views that list only terms with no parent and terms with parents as in (parent view, archive or etc), but that is also not helping you to get closer to your goal.
Hence again Nigel's code should help to get started, as it does exactly that.
It gets the current term and then returns its parent.
There are also core functions of WordPress that help you achieve that:
That should work both on Post Types and Taxonomies.
Or,, which is tailored for taxonomies only.
That can then be returned in a Custom ShortCode and wrapped to an HREF link.
This would then allow producing such "parent" links on child term archives as you mention, but it falls under Custom Code that we cannot produce in a ready to go state.
We can, however, help to review where issues pop up or give ideas like above.

Please let me know if you need more details or struggle with the implementation.


Thank you Beda for your response. I guess I will have to look for alternative ways to do this. Meanwhile we may close this ticket.