Skip Navigation

[Closed] Using parent and child relationships in a taxonomy

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

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

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 2 voices.

Last updated by Christian Cox 2 years, 10 months ago.

Assisted by: Christian Cox.

Author
Posts
#2090163
themes in search.jpg

I am using a new taxonomy called "Temaer" for different psychological issues and areas. My problem is, there're too many now, because the psychologists were able to add them when creating posts. I don't want to delete too many of these "Temaer" items, because they're relevant, we have 39 psycologists with a wide range of focus areas, so these taxonomy items are important.

- I am using these "temaer" all across the website, for sorting content and psycologists based on these areas.
- I also have a search. There's a red button in the right side of the browser window that you can click, you can see one part of the problem here, it uses all of the 'temaer' as sorting options, on mobile it seems never ending.

I'm wondering if I could fix this by selecting some themes to be parents, and others as children.

I would need to:
1. Display only parent taxonomy items from 'temaer' in search.
2. Display only parent taxonomy items from 'temaer' in other contexts
Meaning, that I will be able to display themes based on whether they are parent or child, so that I can have many taxonomy items, but only display the most important ones.
3. In all these different contexts, have child "temaer" link to their parent (e,g. in blog, events, retreats, podcasts, videos and other posts).
E.g. a Parent could be "Family issues" and a child theme "Pregnancy related issues", I would want the latter to link to the archive "Family issues".

We also have a custom post type for "psychological themes" and another one for "psychological methods", these are presented like pages in the navigation, and we attach a "temaer" taxonomy to each custom post
In many contexts when I click a "temaer" name, I am sent to the custom post related to this theme. I've done this by making the short title of the custom posts and the "temaer" taxonomy exactly the same, and adding the base URL to the custom post type and the short title of the "temaer" in a link.
I'm writing this last part, because optimally all the child theme would link the the post of the parent theme. But maybe this can be done by using the child slug in the links. What do you think?

Am I doing this all wrong?
It's honestly become a mess, the site has been built and expanded over many years now and I'm worrying that I've made it all too complicated.

URL hidden link

#2090623

Hello, please find my feedback to your comments below.

1. Display only parent taxonomy items from 'temaer' in search.
Usually when you use the "Add filter" button to insert a taxonomy search filter in a View, the system will automatically include a shortcode like this:

[wpv-control-post-taxonomy taxonomy="book-tax" type="checkboxes" url_param="wpv-book-tax"]

By default, all terms will be displayed as options in the filter and there is no simple, automated way to specify "only parent" terms, or "only top-level" terms, or "only child" terms, etc. That filtering option does not exist in Views, but there is a different shortcode available for a more customized filter control - wpv-control:
https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#vf-153286
You can use this syntax instead of the wpv-control-post-taxonomy shortcode to create a similar taxonomy term checkboxes filter with predefined options:

[wpv-control url_param="wpv-book-tax" type="checkboxes" values="parent-term-1,parent-term-2,parent-term-3" display_values="Parent Term 1,Parent Term 2,Parent Term 3"]

As you can see, the terms and their corresponding slugs must be defined manually in this workaround. The terms must be listed in the display_values attribute, and the corresponding slugs must be listed in the values attribute.

2. Display only parent taxonomy items from 'temaer' in other contexts
The wpv-post-taxonomy shortcode does not provide any options like this to display only parent terms or only child terms. If you are using this shortcode to display terms in some contexts, you will most likely need another solution. A View of terms filtered by term parent = "None" might be a good solution instead of the wpv-post-taxonomy shortcode.
https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#wpv-post-taxonomy

3. In all these different contexts, have child "temaer" link to their parent (e,g. in blog, events, retreats, podcasts, videos and other posts).
Again, the wpv-post-taxonomy shortcode is not flexible enough to provide this feature, so a View of terms is probably required instead of the wpv-post-taxonomy shortcode.
In a View of terms, you can display a link to the current term archive using the wpv-taxonomy-link shortcode: https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#vf-153464
Displaying parent term archive links instead of child term archive links will be a bit more complex, and you may need a custom shortcode solution.

I'm writing this last part, because optimally all the child theme would link the the post of the parent theme. But maybe this can be done by using the child slug in the links. What do you think?
I do not understand how you hope to use the child term slug in links, but redirect to the post of the parent term. How would that work? Can you show me an example?

Am I doing this all wrong?
I think this is a difficult question to answer. It is somewhat subjective. In my opinion, redirecting to a parent archive when clicking a child term link is confusing. I would not expect that behavior, but maybe it is not as noticeable to your site visitors, or maybe they would not find it confusing, it is hard to say. It could also have significant impact on SEO. Removing child terms from a custom search filter can make it difficult to find some posts that have no parent terms assigned.

#2098757

Please keep this ticket open just a while longer, I'm still trying to implement the above and describe issues.
Just writing to let you know, and thanks so much for the helpful tips on alternate solutions.
Kind regards,
Lykke

#2100555

Okay no problem, let me know if you need assistance.

The topic ‘[Closed] Using parent and child relationships in a taxonomy’ is closed to new replies.