Wordpress taxonomy template exclude terms -
i have custom taxonomy. lists of terms in taxonomy dynamically created.
i have custom template taxonomy taxonomy-{custom-template}.php, not want use same template terms page.
i not able create template terms upfront taxonomy-{custom-template}-{term}.php terms created dynamically.
is there option exclude or have generic template terms?
i'd use is_tax() in taxonomy-{custom-template}.php determine whether displaying archive page or terms page, , them include relevant code in template parts.
create 2 new template parts in template parts folder - lets called partials
- one taxonomy archive page e.g. tax_archive_content.php. copy archive-specific code taxonomy-{custom-template}.php it.
- the other terms page - e.g. tax_terms_content.php. put new code handling terms in here.
add following taxonomy-{custom-template}.php
(this replace archive-specific code moved tax_archive_content.php)
if (is_tax()) get_template_part('partial/tax_archive_content'); else get_template_part('partial/tax_terms_content'); references is_tax:
- codex: https://codex.wordpress.org/function_reference/is_tax
- developer.wordpress.com: https://developer.wordpress.org/reference/functions/is_tax/
Comments
Post a Comment