Avoid taxonomy-%term%.php if more than one taxonomy

admcfajn asked
custom-taxonomy templates template-hierarchy
via

I have a site with multiple custom taxonomies which are used for filtering posts.

One of the taxonomies has a taxonomy-%term%.php template file.

/?country=the_country shows the country taxonomy template

but /?topic=the_topic&country=the_country uses the country taxonomy template as well.

Is there a simple way to avoid loading the taxonomy-country.php template if more than one taxonomy is being queried?


Answer
via

See: Template Hierarchy

My suggestion would be to move away from term-specific template files in this case, and instead use only taxonomy.php, where in that file you can work out the logic you need to in order to render the proper output; i.e., you can then detect the use of multiple taxonomies and adjust as necessary.

Share This
Posted in: