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.
3 Answers
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.