Custom Template for one Taxonomy Term
Question
””
Hallo , I have a custom post type called Grants , Taxonomy Called scholarship_degree and a Term Called all-degrees-scholarships. I have made a single-grants but I need now to make a Single Template just for the Term ‘ all-degrees-scholarships ‘ from this Taxonomy ‘ scholarship_degree ‘. I have tried this code but the Problem I do not want to register this Single Term Template for all other Terms . Any Help
the Code which I am using :
function get_grants_degrees_single_template($single_template) {
global $post;
if ($post->post_type == 'grants') {
$terms = get_the_terms($post->ID, 'all-degrees-scholarships');
if($terms && !is_wp_error( $terms )) {
foreach($terms as $term){
$single_template = dirname( __FILE__ ) . '/single-'.$term->slug.'.php';
}
}
}
return $single_template;
}
add_filter( "single_template", "get_grants_degrees_single_template" ) ;
0
terms
3 years
2020-04-01T20:51:20-05:00
2020-04-01T20:51:20-05:00 0 Answers
72 views
0
Leave an answer