1

For a local directory, i have a 'businesses' CPT with 2 taxonomies - 'location' and 'type'.

I am trying to figure out the best way to create taxonomy term archive pages such as:

example.com/state/city/bakeries
example.com/state/city/restaurants
example.com/state/city/spas
etc

After a few hours of searching, this is what i've come across:

a) A custom taxonomy (term) archive template file is needed: taxonomy-$taxonomy-$term.php

b) This posts talks about using 'tax_query'

http://cheekymonkeymedia.ca/blog/using-wordpress-query-multiple-taxonomies

c) This post seems to have most of the essential ideas (&code) but it combines and lists all the second taxonomy's posts in the same page, whereas i would like to list them in individual pages.

http://code.tutsplus.com/tutorials/taxonomy-archives-list-posts-by-a-second-taxonomys-terms--cms-20450

Just to clarify. AFAIK, it queries the first taxonomy (location) and gets the term 'Seattle', and then queries the second taxonomy (type) in order to list all the second taxonomy terms and posts (that are in both the first and second taxonomies) on the same page:


SEATTLE

Bakeries
- Post Title 1
- Post Ttile 2

Restaurants
- Post Title 5
- Post Title 4
- Post Title 6

Spas
- Post Title 9


Questions:

1) The result above is suitable for a 'location' taxonomy terms archive page ie. "example.com/state/city" but how do i modify the code from the TutsPlus article to get an archive page that filters both 'location' & 'type' taxonomies to produce something like "example.com/state/city/bakeries"?

2) Since 'Seattle' and 'Bakeries' are both taxonomy terms, does this solution lie in the same "taxonomy-$taxonomy-$term.php" file even though they are terms from different taxonomies?

3) Ideally, it would be good to be able to have archive pages for "example.com/state/bakeries" too. Does this mean that states and cities would need to be in separate taxonomies? The current plan is to have cities as a child of states under the same taxonomy 'location'.

Note: i am new to PHP and can copy/paste examples together by trial & error. I think the solution may include parts of b) and c) but i just don't know how to write the code.

Thanks for your suggestions & feedback.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.