Archive template for taxonomy terms

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:

http://hostname/post_type/taxonomy_term

Instead, you are going to find the url in:

http://hostname/taxonomy_slug/taxonomy_term

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

taxonomy-taxonomy_slug-taxonomy_term.php

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

http://hostname/taxonomy_slug/taxonomy_term

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

get_the_term_list($post->ID,'taxonomy_slug')

And test wherever the link is going to point to.

Leave a Comment