I created the taxonomy 'machine types', and added several terms to it, like 'cranes' for example.

The url to that term now looks like this: domain.com/machine-types/cranes

How can I make this url query for only posts with the term cranes? And the same for all other terms, without creating a template for each term.

I think I must ask for the current term and store it in a value, and query for that, right? How?

1 Answer 1


You can create a taxonomy.php file and put your loop/query inside this file and as such anytime you are on a taxonomy page, no matter the term, be it cranes, bulldozers, etc the taxonomy.php will take over and handle the term in question (as shown in your URL).

Taken from the WordPress Codex, this is the template hierarchy - the order in which what files take precedence over another for taxonomy pages.

Custom Taxonomies display

  • taxonomy-{taxonomy}-{slug}.php - If the taxonomy were sometax, and taxonomy's slug were someterm WordPress would look for taxonomy-sometax-someterm.php. In the case of Post Formats, the taxonomy is 'post_format' and the terms are 'post-format-{format}. i.e. taxonomy-post_format-post-format-link.php

  • taxonomy-{taxonomy}.php - If the taxonomy were sometax, WordPress would look for taxonomy-sometax.php

  • taxonomy.php

  • archive.php

  • index.php

So as you can see if you need to you can also customize the template file right up to the individual taxonomy term, or taxonomy (if you have more than one).

  • Thanks. I have several different taxonomies which I might want to display differently, so I ended up using taxonomy-mytaxonomy.php.
    – Johan Dahl
    Jun 20, 2012 at 12:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.