Take the 2-minute tour ×

I have registered a custom post type [equipment] and have a taxonomy of [equipment_type] within the taxonomy I have parent and child categories. For example:

Equipment (Custom post type)

Equipment Types (Taxonomy)

Cameras (Parent term)

  • Camera A (Child term)

  • Camera B

What I would like to create is effectively an archive page for the taxonomy terms. So when either 'Cameras' or 'Camera A' is selected it shows say 12 posts with title and featured image (links to single post) plus some pagination.

I have tried a standard WP query and Loop and it always ends up showing all of the taxonomies posts in all terms.

I currently have a taxonomy-equipment_types.php template set up to handle the query.

share|improve this question
Please explain what you mean by Taxonomy Category. Your question conflates taxonomy and category (which is one type of taxonomy). Are you saying that you have hierarchical terms for your custom taxonomy, equipment_type? Also, is cameras a term for the equipment_type taxonomy? –  Chip Bennett Dec 7 '12 at 19:00
My apologies, perhaps I am confusing the terminology. I have a taxonomy of 'equipment_type' and within that I have 'cameras', 'lenses' etc... are those terms? They are Hierarchical and act like categories would on posts within the standard WP setup. –  user1833715 Dec 7 '12 at 19:07
Ah, now you have it! cameras, lenses, camera-a, and camera-b are terms of the equipment_type taxonomy. The camera-a and camera-b terms are children of the cameras term. –  Chip Bennett Dec 7 '12 at 19:45
Thank you for clarifying toscho I appreciate it. –  user1833715 Dec 7 '12 at 19:48

3 Answers 3

The WordPress Template Hierarchy provides the exact template file that you need: taxonomy-{taxonomy}-{term}.php.

So, to create a custom template for the cameras term of the equipment_types taxonomy, you would create a file named taxonomy-equipment_types-cameras.php.

(Note, you can also create a template file for the taxonomy itself; just omit the {term} slug: taxonomy-{taxonomy}.php, or taxonomy-equipment_types.php in your case.)

You can conditionally output content based on hierarchy by querying for either the term parent, via the object properties returned by get_term(), or the term children, via get_term_children().

share|improve this answer
Thanks Chip, I thought the WP template provided what I needed as you suggested: taxonomy-equipment_types.php I think where I am struggling is working out how to output the content / posts based on the user selected terms for both parent and or child, cameras or cameras-a. Are suggesting I use 'get_term()' to decipher which content / posts should output in the loop? I'm fairly new to PHP and currently learning through Lynda.com. So I'm going to have to delve in a little more and try to understand the process. Could you provide a rough example to help me understand what I need to do? –  user1833715 Dec 8 '12 at 13:10

I want to document this because I just found the answer recently.

The problem with having taxonomy is that most developers have the mindset of expecting the taxonomy to be seen inside the post_type url of:


Instead, you are going to find the url in:


This means that we often may be creating the template correctly as


But the right way of using it is to expect it inside the url


To view the correct url for the taxonomy, we can use


And test wherever the link is going to point to.

share|improve this answer

I had a similar issue. The problem with the above answers is that they all require you to specify the CPT, the taxonomy or the term.

If - as you've indicated - you want to retrieve this dynamically depending on which CPT page the user is on, you can try the following (which works for me), which displays all the taxonomies for the current custom post type.

(originally from this post with the help of GhostToast)

 <?php get_header(); ?>
  <div id="content">
<div id="main">


<? // Start taxonomy term archives query
$post_type = get_post_type(); // find out CPT name
$taxonomies = get_object_taxonomies($post_type); // Find taxonomies
foreach($taxonomies as $taxonomy){
// only want hierarchial -- no tags please

    $terms = get_terms($taxonomy, array(
'orderby'       => 'name', 
'order'         => 'Asc',
'hide_empty'    => true )); 

 foreach ( $terms as $term ) {  

// example output below ?>


 <h1><a href="<?php echo get_term_link($term->slug, $taxonomy); ?> "><? echo $term->name; ?></a></h1>

   <div class="imgBox">

     <a href="<?php echo get_term_link($term->slug, $taxonomy); ?> " title="<? echo $term->name; ?>" >
     <img src="<?php echo get_template_directory_uri(); ?>/timthumb.php?src=/library/images/dingy-placeholder.png&amp;h=196&amp;w=285&amp;zc=1" alt="<?php the_title(); ?>" /></a>

           <div class="the-excerpt">
            <a href="<?php echo get_term_link($term->slug, $taxonomy); ?> "><? echo $term->description; //you can add this in admin ?> - click to view more</a>



<?php wp_reset_query(); ?>


 <?php get_footer(); ?>

Save the above in a file called something like archive-mycpt.php, then in archive.php add this after the header call;

<?php get_header(); ?>

<?php  // is this one of our CPT ? If so, direct to custom archive page 
  if ( is_custom_post_type() ){ 
include (TEMPLATEPATH . '/archive-mycpt.php'); 

        // if not continue...

    } else {  ?>

               <!-- archive.php content   -->

   <? } ?>
share|improve this answer

Your Answer


