The hierarchy picture doesn't tell me exactly which one is dominant.
/search/query/?category_name=general&post_type=custom
/category/general/?s=query
/tag/any/?s=query
/custom_post/?s=query&custom_tax=term
/?s=query&custom_tax=term&post_type=custom
When I tested the links I gave above, I could not draw any conclusions. When we open these links, I do not understand which archive file it prefers.
Sometimes it goes to archive.php
while opening search.php
in some cases.
Outside of this hierarchy, is there any indication of what it prefers when it comes to equivalence?
The hierarchy picture doesn't tell me exactly which one is dominant.
/search/query/?category_name=general&post_type=custom
/category/general/?s=query
/tag/any/?s=query
/custom_post/?s=query&custom_tax=term
/?s=query&custom_tax=term&post_type=custom
When I tested the links I gave above, I could not draw any conclusions. When we open these links, I do not understand which archive file it prefers.
Sometimes it goes to archive.php
while opening search.php
in some cases.
Outside of this hierarchy, is there any indication of what it prefers when it comes to equivalence?
Share Improve this question edited Mar 3, 2021 at 13:49 Tom J Nowell♦ 61k7 gold badges79 silver badges148 bronze badges asked Mar 3, 2021 at 13:23 PelmiPelmi 31 bronze badge 1 |1 Answer
Reset to default 0The answer is simple:
/search/query/?category_name=general&post_type=custom
is not a part of WordPress and has been added by a plugin/theme, you need to ask their support or inspect the code to find out
For everything else, if is_search()
is true, then it's a search archive. If is_search()
is not true it is not a search archive.
Since all of those URLs have ?s=
they are all searching for things, so they are all search archives.
We know this because it shows search.php
, and because the body class is:
class="archive search search-results category category-maintenance category-39 logged-in admin-bar customize-support"
You shouldn't need to know the priority of template to know which template is currently loaded. WordPress shares this information openly if you built the theme correctly, debugging tools will tell you, and you can always put this is the search template at the top of search.php
and see if the text appears.
/search/query
is not a WordPress rewrite rule, it's a custom rewrite rule added by a plugin or theme. Can you not use a debugging tool to test which template it loads? Or inspect the body class? Note that WordPress is not a man woman or person, use it instead of he/she/they – Tom J Nowell ♦ Commented Mar 3, 2021 at 13:40