WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I read the answer for this post which says you can do something like this:


When viewing $wp_query everything seems to be working fine. That is, I'm getting 'car' post types that have the 'red' term assigned. However, the request uses the 'color' custom taxonomy template. (In my case this is taxonomy.php.)

How can I get this request to use the 'archive-car.php' custom post type template instead?

share|improve this question
up vote 0 down vote accepted

Switch the taxonomy.php just like you would the single.php to support specific post custom templates. This is untested code, so it may not work - but, first get the post type

$post_type = get_query_var('post_type');

So if $post_type contains post_type = 'car' then include archive-car.php like this:

if ( $post_type = 'car' ) 
elseif ( $post_type = 'boat'  ) 
elseif ( $post_type = 'bike' ) 

An better alternative would be if you could establish a template redirect like in this answer, but I don't know if that's even possible. If possible, you'd redirect the taxonomy template based on the value of $post_type.

How to quickly switch custom post type singular template?

share|improve this answer
This looks like it will work for my situation. I would also recommend using get_template_part('archive-car'); instead of the include() call. Thank you! – robertwbradford Aug 3 '11 at 15:48
Also, the 'cars' should be 'car' in your example above :) – robertwbradford Aug 3 '11 at 15:50
fixed cars to car – marfarma Aug 3 '11 at 16:32
and changed include() call to get_template_part, per @robertwbradford recommend – marfarma Aug 3 '11 at 16:37

I'm not sure that's possible. My understanding is that whenever you are viewing posts that are filtered by a taxonomy wordpress looks for taxonomy templates. Based on hierarchy you could get rid of any taxonomy pages and only have archive pages available as templates, but that seems a bit extreme and not too useful.

What are you hoping to achieve with this code?

You could build functions into your archive-car.php page to react to cars in a specific color term. Perhaps that will get you the functionality you're looking for.

share|improve this answer
I know this should be a comment, sorry it's not. – Aris Blevins Aug 2 '11 at 20:09
Thanks for the reply. I had originally tried adding some work-around functionality to the archive-car.php like you suggested, but this required me to start using different parameter names for the taxonomy in the query string. Started to get a little messy... Thank you though. – robertwbradford Aug 3 '11 at 15:52

Your Answer


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.