2

I'm hoping someone can help me fill in the gaps in my understanding of page templates and query vars:

I've registered a custom taxonomy 'stream', and have set up a page template for that taxonomy, taxonomy-stream.php. The page template lists an archive of posts that are using the respective taxonomy term. Everything there works fine.

I'm trying to add a filter to the sidebar to allow the user to narrow down the taxonomy archive of posts based on Categories. I am finding that if I add a query var to the URL (?category_name=text, for example) that the page template switches from my taxonomy-stream.php template to archive.php. My goal, however, is for the ?category_name=test query var to limit the results of the taxonomy archive.

The query var itself seems to be changing the page template to archive.php instead of keeping it on the taxonomy-stream.php template. What am I missing here?

0

The problem is that category_name is a reserved keyword for the built-in categories for posts. Almost anything category_* is reserved. You can find a list of reserved keywords at the following url:

https://codex.wordpress.org/Reserved_Terms

This includes, but is not limited to:

  • cat
  • category
  • category__and
  • category__in
  • category__not_in
  • category_name
  • term
  • terms

Behind the scenes it sees that you're using the category_name reserved keyword. It knows categories are a taxonomy of posts and switches to the archive.php template. If the archive.php template did not exist it would default to index.php and try to load posts looking for anything in the test category (taxonomy).

  • 1
    Thanks for taking the time to explain this. This is what I suspected was happening. It's been a frustrating problem. In the end I swapped these from archives to proper pages and used wp_query instead of the loop. Then I decided to go with the Search and Filter plugin for the particular filtering functionality I was having trouble with. – alanbrown-ca Jun 24 at 15:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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