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?
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?
Share Improve this question asked Jun 19, 2019 at 20:55 alanbrown-caalanbrown-ca 233 bronze badges1 Answer
Reset to default 0The 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/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).
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745386961a4625482.html
评论列表(0条)