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
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:
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.
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.