Filter posts by 2 taxonomies
-
Hi. I’m trying to find a way to display posts by a taxonomy over another taxonomy (if that makes sense). I found several topics online, but i don’t know how to apply those solutions to my situation.
I have a post type called “services” and 2 taxonomies, one called “region” and the other “service_category”.
The region tax have 15 terms (region 1, region 2…), and in the service_category tax have 13 terms (sports, health, fashion…).
The “service_category” terms must be applicable to each “region”term.The idea is that a user choose one of those regions, let’s say “region1” and, in the next page, selects one “service_category” like “sports”. I need to display all the posts that fit, first in region 1, and then sports.
And maybe another user selects region 2, then I need to filter that region by the same “service_category” tax.
I should mention that the users can post services in a frontend form, so I can’t implement a solution like create child terms like “sports” on every “region” term. Because when the user selects in what region post its service, he would see something like
region1
— sports
— fashion
region2
–sports
–fashionSo that solution doesn’t apply to me. What I need is that the user select the “region” in one field and the “service_category” in another field. That’s done, I have no problem with it, but I having trouble to think a logical and correct way to display posts based on a “region” and “service_category”.
And the other thing. What should be the correct template hierarchy for this situation?
Thank you all.
- The topic ‘Filter posts by 2 taxonomies’ is closed to new replies.