Frage

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?

War es hilfreich?

Lösung

The 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.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit wordpress.stackexchange
scroll top