I have a custom taxonomy called "feature" which setup like this.
Cat 1
--------Sub 1
--------Sub 2
--------Sub 3
--------Sub 4
Cat 2
--------Sub 5
--------Sub 6
I've created a custom WordPress archive for feature.
Question 1:
How to show parent title which is "Cat 1" when I'm in sub1 archive page (www.mydomain.com/feature/cat1/sub1)?
Question 2:
How to list all sub categories and it's url under the same level?
Please see the image for what I mean. Thanks
Hello and thank you for contacting the Toolset support.
Regarding the first question, I'll suggest you try this:
1) Create a content template, for example "parent-infos", in the content, display below shortcode:
[wpv-post-taxonomy type='building']
2) use above content template to display parent category, fore example:
[wpv-post-body view_template="parent-infos" id="$parent-slug"]
For the second question, I'll suggest using another content template and putting a taxonomy view inside of it, the taxonomy view will query the terms who's parent is the current term.
Please note, that the block-based views and content template do not support taxonomies yet. You will need to build this with the legacy shortcodes, or you can build your own shortcodes to get the expected results.
To activate the legacy editor, go to Toolset->Settings->General->Editting Experience.
Read more about the shortcodes here:
- https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-post-taxonomy
- https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-post-body
Just let you know that I'm aware the link here.
https://toolset.com/forums/topic/show-parent-category/
But It's just not working. Please see the attached image and provide more details.
I'm editing WordPress archive page for "Feature".
Feature is a custom taxonomy for Product post type which is also a custom post type by toolset.
Feature has hierarchical like this:
Cat 1
--------Sub 1
--------Sub 2
--------Sub 3
--------Sub 4
Cat 2
--------Sub 5
--------Sub 6
When go to the URL hidden link
It means I'm in Sub1 's archive page. And I'd like to display Cat 1 on that archive page which is Sub1 's parent.
How? Is it possible?
I run a test locally and I came up with the following custom shortcode that returns the topmost parent. So, if we go to the URL hidden link it will return Cat 1. And if we go to the URL hidden link it will return Cat 1.
add_shortcode('top-most-parent', 'jts_get_term_top_most_parent');
// Determine the top-most parent of a term
function jts_get_term_top_most_parent( $atts ) {
// get the term and taxonomy
$term = get_queried_object ();
$taxonomy = $term->taxonomy;
// Climb up the hierarchy until we reach a term with parent = '0'
while ( isset($term->parent) && $term->parent != '0' ) {
$term_id = $term->parent;
$term = get_term( $term_id, $taxonomy);
}
return $term->name;
}
Check this screenshot hidden link
However, for support rules, we are able to handle only one issue at a time. This helps us to bring you a better service and also helps other users to find all the information here exposed. For that reason, I have to kindly ask you to open a new ticket if you still need assistance with your 2nd question.
My issue is resolved now. Thank you!