WordPress Taxonomy Term Page Template

after several hours of testing and development I need your help.

I’ve created a taxonomy with several (free) terms. After that I’ve created the page and sub pages for displaying the taxonomy, following the scheme from WordPress.

Read More

Following the hierarchy I need to create a page like taxonmy-{taxonomy}-{term}.php for every single term within my taxonomy. I need that subpages for a filter option.

Is there a way to create that subpages dynamically? The user creates terms by himself and I have no clue how they will be named.

Thanks for help.

Related posts

Leave a Reply

2 comments

  1. See this solution which hooks into the ‘template_include()’ filter. You’ll check your specific taxonomy and redirect the $template at the end

        ....
        add_filter('template_include', array($this,'my_template_include'));
    }
    
    function my_template_include($template){
    global $wp_query;
    var_dump($wp_query);
    return $template;
    }
    
  2. I tend to write it like this, but generally @emeraldjava has it right

    /********** Set Taxonomy Template ***********/
    add_filter( 'template_include', 'tax-name_taxonomy_template' );
    function tax-name_taxonomy_template( $template  ){
        if (is_tax('tax-slug')){
            $template = dirname(__FILE__).'/taxonomy-tax-slug.php';
        }
        return $template;
    };