Rewrite for Archives of one Custom Taxonomy and several CPT’s

First, I know there’s a myriad q&a about this topic, but I can’t seem to find any that matches my specific problem. Maybe it simply can’t be done the way I want it.

I have one Custom Taxonomy called Locations, with slug locations, which is hierarchical.
Then, there are several CPT’s like Hotels, Hospitals, etc. All of them are classified in that same taxonomy Locations.

So, for every single post, the url is:

example.com/hotels/hotel-plaza
example.com/hospitals/general-hospital

Fine. Then, with this simple scheme, you would go to example.com/usa and that page would show you all hotels AND hospitals in the USA.
When going to example.com/usa/california/san-francisco you would find all items (of all cpt’s) of that city.

What I would like to know is if there is a way of setting this up so you can go to example.com/hotels/usa/california and see only the hotels that are in California and go to example.com/hospitals/usa/california/san-francisco and see only the hospitals in San Francisco.

Thanks in advance.

Read more here: Rewrite for Archives of one Custom Taxonomy and several CPT’s

Leave a Reply

Your email address will not be published. Required fields are marked *