How to get custom taxonomy terms based on another taxonomy?
How to list out all the terms of a custom taxonomy that are relative in another custom taxonomy?
I am creating a filter page for a CPT with multiple custom taxonomies.
Please see the screenshot below:
- Custom Post Type: English “cpt_english”
- Custom Taxonomy: Courses
- Terms: course-a, course-b, course-c
- Custom Taxonomy: Difficulties
- Terms: easy, advanced , pro
- Custom Taxonomy: Tasks “tasks”
- Terms: task1, task2, task3, task4
The screen is html markup, not php generated code.
How can I list out all the terms of a taxonomy based on another taxonomy?
For example, The type: “Task 1” has “Difficulty”: Easy, Advanced, Pro”
But “Task 2” only has “Easy” and “Pro” … so when clicking Task2, I do not want to show “Advanced” there, and Task 3 doesn’t even has “Courses”… how can I achieve it with coding?
So what I meant is that, amount all the CPT that are associated with “Task1″(term name) of a custom taxonomy “task”, these posts are also associated with term “easy”, “advanced” and “pro” from another taxonomy “difficulty”
However, amount the CPT items associated with “Task2”, none of them are associated with “advanced” … so I do not want to list out “advanced” there
I know I can use “get_terms” and then “foreach” to list out all the terms of a taxonomy.
But how I can “get_terms of taxonomy_a based on taxonomy_b” ?