Tell us what you are trying to do?
I have Hierarchical Product Categories:
Veneer
- Thin Stone Veneer
- Stone Panels
...
Hardscape
- Pebbles
- Cobblestone
...
In the archive I need to show only the sub-categories when the current archive is the parent term of Veneer or Hardscape.
If the current archive is one of the children (Thin Stone Veneer, Pebbles, etc.) I need to show the products in that category.
Is there any documentation that you are following?
I tried following this thread: https://toolset.com/forums/topic/display-sub-category-on-top-level-display-posts-on-lowest-level/
but it seems to see the products in the child categories as being also in the parent category (they are not) so the items found count is always greater than 0.
What is the link to your site?
Look at hidden link for a page where products (and the filter) should not be showing because it is a parent category that should be showing its sub-categories.
Look at hidden link for a page where the products should be, and are, showing correctly.
Basically I need to conditionally prevent the main loop and the filter if the term has no parents and instead show a different view that shows the child categories. I need to do this in the archive because the user can click to the parent term through breadcrumbs and category links. Otherwise I'd just build separate pages and views that aren't archives and put those in the menu.
The screenshot shows what I'd like to display when on a top-level category (one with no parent).
Hello,
There isn't such a built-in feature, there is a workaround you can try:
Create a taxonomy view, list terms of "Hierarchical Product Categories", filter by:
Select taxonomy terms whose parent is the current taxonomy archive.
In the section "Loop Editor", within shortcode:
[wpv-no-items-found] ... [/wpv-no-items-found]
Output some javascripts, use it to hide the main loop section of archive page.
Then put above taxonomy view into your archive page.
More help:
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-no-items-found
Content wrapped with [wpv-no-items-found][/wpv-no-items-found] will be output if there are no posts, taxonomies or users returned by the View.
Luo, are you saying that no items found will be true even if the archive loop shows posts associated with child terms in the hierarchy of the taxonomy as long as there are no posts in the parent term?
I'd think either the loop would run or the no items found would run but never both.
I think I'm still not quite understanding what goes in which view (the archive and the new view you're recommending). Or I'm not understanding how the javascript to hide the output of the main loop will know when to hide it (if we're showing the top-level term with no parent) or not hide it (if we're showing a term with a parent term and need to show the product posts).
That said, you've given me another idea. If I give a unique ID or class to my main loop output, I can write my own shortcode to test the current term and whether it has a parent and then output the need CSS or javascript to hide the product posts that way and still use a view (outside the main loop) to show child categories. I'll give this a try but would still appreciate just a little more clarity on what goes where to make the workaround you're suggesting work.
Q) are you saying that no items found will be true even if the archive loop shows posts associated with child terms in the hierarchy of the taxonomy as long as there are no posts in the parent term?
It is a taxonomy view, so "no items found" will be true when there isn't child term.
As you mentioned above:
Basically I need to conditionally prevent the main loop and the filter if the term has no parents and instead show a different view that shows the child categories.
https://toolset.com/forums/topic/show-different-content-if-term-is-parent-than-if-it-is-child-in-taxonomy-archive/#post-1002765