Skip Navigation

[Resolved] Create a hierarchical list of Taxonomies (parent, child, etc)

This thread is resolved. Here is a description of the problem and solution.

Problem:
How to create a hierarchical list of taxonomy terms by their hierarchy.

Solution:
https://toolset.com/forums/topic/dropdown-menu-widget-for-taxonomy/#post-823316

This support ticket is created 6 years, 8 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
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

This topic contains 2 replies, has 2 voices.

Last updated by weatherlyB 6 years, 7 months ago.

Assisted by: Beda.

Author
Posts
#816077
sidebar-categories.jpg

We are trying to do a category list where the parent categories / taxonomies (in this case locations) show, but the sub categories only show if you click on them. Is there any way to do this?

If we can't have the parent category expandable we'd at least like to have the child category indented under the parent. Right now its all listed at the same level.

Here is an example page: hidden link

#823316

You can create a View (Parent Taxonomy View) and select to query the taxonomy you use, then add a Query Filter like this:

Select taxonomy terms whose parent is None.

Then, create another View (Child Taxonomy View), and again query your taxonomy and add this Query Filter:

Select taxonomy terms whose parent is the value set by the parent view.

Now insert for example the terms Title shortcode in this View's loop:

[wpv-taxonomy-title]

Then, head back to the first View (Parent Taxonomy View), and in that Loop, you insert again the terms Title Shortcode and the second View (Child Taxonomy View) you created:

<wpv-loop>
  [wpv-taxonomy-title]
  [wpv-view name="child-taxonomy-view"]
</wpv-loop>

This View (Parent Taxonomy View) you insert into a Page, where you will be able to see a list like this:
- Parent Term
-- child
-- child
- Another Parent
-- child
-- child

To add indentation or accordion similar functionality, I suggest using Bootstrap HTML structures around the ShortCodes I mention above.

#889250

Thanks. We went another route since this seemed too much for the client to handle if they wanted to add a category. But we will keep it in mind for the future.