Show list of custom taxonomies when another taxonomy is selected

Hard question to explain here. So here goes:

I have a chapter/section scenario I’m trying to work out. The custom post type of “Books” has two custom taxonomies, “Chapters” and “Sections”. The Chapters, are sort of like the higher level taxonomy with Sections being inside each chapter. So it would look something like this:

Read More
  • Chapter 1

    • Section 1.1
    • Section 1.2
    • Section 1.3
    • Section 1.4
  • Chapter 2

    • Section 1.1
    • Section 1.2

Basically, I’m trying to list out the sections, relative to the specific Chapter on a Chapter taxonomy page. I’m using get_terms() to grab the list of section taxonomies. The problem is, when I use get_terms() it lists out every section in all Chapters. So for instance, Chapter 2 only has posts with Sections 1.1 and 1.2 selected. But using get_terms() lists out Sections 1.3 and 1.4 as well for that Chapter.

I need a way to isolate the sections taxonomy list to only those taxonomies which are selected in conjunction with the selected Chapter taxonomy.

In a way, it’s sort of like this question here

Related posts

Leave a Reply

1 comment