Tell us what you are trying to do?
Hello I would like to show the categories and prepend text in front of the parent and the child like this:
e.g. Subject Area: Cat A - Topic: Sub A2
No links just the text.
Is there any documentation that you are following?
https://toolset.com/forums/topic/display-wpv-post-taxonomy-and-hierarchical-taxonomies/
This is a good start but missing A) the text in front of the parent and child B) Is linked C) Has a separator trailing
Hi, I can help you tweak this a bit.
Will all posts have 1 parent and 1 child term from this taxonomy, or will there ever be a post with multiple parents, no parents, multiple children, or no children?
Hi Christian,
as of right now it is only foreseen to have 1 parent and 1 child. So let us go with that please 🙂
Michael
In that case, I think it's easiest to disregard the thread you were looking at before, and start from scratch.
- Create a new View of the post type where you intend to show this hierarchical category information. Uncheck the option "Don't include current page in query result", then add a Query Filter on post ID. Include "Posts with IDs set by the View shortcode attribute: ids". This is called passing an argument into a View, and it means that your View will search for all the posts that match the IDs coming from the ids shortcode attribute. More info about arguments here: https://toolset.com/documentation/user-guides/passing-arguments-to-views/
See settings.png for the settings I just described.
- In the Loop Output of this View, use the wpv-post-taxonomy shortcode to display all the terms from your hierarchical taxonomy. This will work since there are only two terms, parent and child. Add the "Subject Area: " text before the shortcode, and add the ", Topic: " text as the separator. Example:
Subject Area: [wpv-post-taxonomy type="category" separator=", Topic: " format="name" order="asc"]
More information about the post taxonomy shortcode here:
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-post-taxonomy
- Finally, insert your new View in a Layout, Content Template, or page body using the wpv-view shortcode, and pass in the current post's ID as a shortcode attribute "ids" so your View's filter knows which post to query:
[wpv-view name="your-view-slug" ids="[wpv-post-id]"]
More information about the View shortcode: https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-view
Let me know the results, or if you get stuck somewhere.