Skip to content

Instantly share code, notes, and snippets.

@lamberger
Created October 1, 2018 17:46
Show Gist options
  • Select an option

  • Save lamberger/2e508f7f1fbcce525cd605af45241b99 to your computer and use it in GitHub Desktop.

Select an option

Save lamberger/2e508f7f1fbcce525cd605af45241b99 to your computer and use it in GitHub Desktop.
Targets all terms in news and article taxonomies
function pjl_single_tax_term_template( $single_template ) {
global $post;
//has_term( $term, $taxonomy, $post );
if ( has_term( '', 'news' ) ) {
$single_template = dirname( __FILE__ ) . '/news.php';
}
if ( has_term( '', 'article' ) ) {
$single_template = dirname( __FILE__ ) . '/article.php';
}
return $single_template;
}
add_filter( 'single_template', 'pjl_single_tax_term_template' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment