Skip to content

Instantly share code, notes, and snippets.

@Asikur22
Created February 12, 2022 04:56
Show Gist options
  • Save Asikur22/e4e181d8635e678fdf86549d840adbd5 to your computer and use it in GitHub Desktop.
Save Asikur22/e4e181d8635e678fdf86549d840adbd5 to your computer and use it in GitHub Desktop.
Set Single template for Taxonomy Term #single-taxonomy-term.php
add_filter( 'template_include', function ( $template ) {
if ( is_singular( 'POST_TYPE_NAME' ) ) {
$term = get_the_terms( null, 'TAXONOMY_NAME' );
$new_template = locate_template( array( 'TEMPLATE_NAME.php' ) );
if ( isset( $term[0]->slug ) && $term[0]->slug == 'TERM_NAME' && '' != $new_template ) {
return $new_template;
}
}
return $template;
}, 99 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment