Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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:

  • 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

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

It would make more sense for the sections to be child terms below each chapter. See my answer to the similar question you referenced as well as MikeSchinkel's explanation of hierarchical taxonomies.

Using the the term_id returned from get_terms use get_term_children to get the sections associated with each chapter.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.