WordPress hierarchy clarification, does post_type_archive take precedence over taxonomy-term archive?

Question

Looking at the hierarchy diagram indeed the post_type archive is above the taxonomy however aren’t they parallel and isn’t taxonomy-term-archive more specific?

the permalink: domain.com/cpt1/term1_of_ctax1/term1_of_ctax2

the resulting matched query:

ctax2=term1_of_ctax2
&ctax1=term1_of_ctax1
&post_type=cpt1
&taxonomy=ctax2
&term=term1_of_ctax2

With the matched_query including specific taxonomy and term query_vars the template hierarchy list from Query monitor does include taxonomy-ctax2-term1_of_ctax2.php however the actual page is rendered using the post_type archive-cpt1.php.

My confusion arises because in the template-loader.php "tax" is processed after post_type_archive which I believe would mean that tax template should be take precedence over post_type_archive right?

Query monitor template results:

Template File

archive-ctp1.php

Template Hierarchy

taxonomy-ctax2-term1_of_ctax2.php
taxonomy-ctax2.php
taxonomy.php
archive-cpt1.php
archive.php
index.php
0
ardv 1 month 0 Answers 6 views 0

Leave an answer