As part of a post template, I am trying to add a section to the top that gives a list of nested taxonomies. Each post belongs to a taxonomy that may have 2 to 5 parents. I am providing a screenshot of what I would like to achieve. Each line is a taxonomy that the post belongs to. At this point, I can use <br> as a separator, but that does not provide indentation. I can also but in
<br><span style="padding-right:5px"><span>
but that just indents lines 2 on and it does not nest the lines.
Hello,
I assume we are talking about a Hierarchical taxonomy, and you are going to display the result like this:
- Grandparent term A
-- Parent term B
---- Post 1
---- Post 2
-- Parent term c
---- Post 3
---- Post 4
If it is, it is possible with nested view, for example:
1) Top level taxonomy view:
- Query terms of your custom taxonomy
- Filter by:
Select taxonomy terms whose parent is None.
- In view's loop, display below 2nd level taxonomy view
2) 2nd level taxonomy view
- Query terms of your custom taxonomy
- Filter by:
Select taxonomy terms whose parent is the value set by the parent view
- In view's loop, display below post view
3) 3rd level post view:
- Query posts
- Filter by:
Select posts with taxonomy:
your custom taxonomy set by the parent Taxonomy View
- In view's loop, display post information
More help:
https://toolset.com/documentation/user-guides/views/using-a-child-view-in-a-taxonomy-view-layout/
Views Inside Views – Display Nested Multidimensional Lists
Does this method work under the new "Blocks?" I can't seem to find the referenced queries. I switched back to Views and worked with it. Here is the catch. I am using the view in a custom post type Template. So I only want to show the taxonomies associated with the displayed post.
Grandparent Taxonomy
Parent Taxonomy
etc.......
POST BODY
The new "Block" editor does not support taxonomy view, so in your case, I suggest you try with legacy View interface, for example:
1) Top level taxonomy view:
- Query terms of your custom taxonomy
- Filter by:
a) Taxonomy is set by the page where this View is inserted
b) Select taxonomy terms whose parent is None.
- In view's loop, within shortcode <wpv-loop>...</wpv-loop> display below 2nd level taxonomy view
2) 2nd level taxonomy view
- Query terms of your custom taxonomy
- Filter by:
a) Taxonomy is set by the page where this View is inserted
b) Select taxonomy terms whose parent is the value set by the parent view.
- In view's loop, within shortcode <wpv-loop>...</wpv-loop> display below 2nd level taxonomy view's itself shortcode
3)in single post content of your custom post type, display:
- Shortcode of Top level taxonomy view
- Post body of current post