Skip Navigation

[Resolved] Display of hierarchical taxonomies

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

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 7 years, 3 months ago.

Assisted by: Christian Cox.

Author
Posts
#563364

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

#563387

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?

#563506

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

#564016
settings.png

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.