WordPress Version: 4.3
/**
* Retrieve path of taxonomy template in current or parent template.
*
* Retrieves the taxonomy and term, if term is available. The template is
* prepended with 'taxonomy-' and followed by both the taxonomy string and
* the taxonomy string followed by a dash and then followed by the term.
*
* The taxonomy and term template is checked and used first, if it exists.
* Second, just the taxonomy template is checked, and then finally, taxonomy.php
* template is used. If none of the files exist, then it will fall back on to
* index.php.
*
* The template path is filterable via the dynamic {@see '$type_template'} hook,
* e.g. 'taxonomy_template'.
*
* @since 2.5.0
*
* @see get_query_template()
*
* @return string Full path to taxonomy template file.
*/
function get_taxonomy_template()
{
$term = get_queried_object();
$templates = array();
if (!empty($term->slug)) {
$taxonomy = $term->taxonomy;
$templates[] = "taxonomy-{$taxonomy}-{$term->slug}.php";
$templates[] = "taxonomy-{$taxonomy}.php";
}
$templates[] = 'taxonomy.php';
return get_query_template('taxonomy', $templates);
}