Answer the question
In order to leave comments, you need to log in
How to create custom taxonomy post template?
What we have:
custom post type created - tur
custom taxonomy - country
taxonomy contains category (term) - iceland
There are several posts in iceland 1,2,3
Question - How can I create a single template only for displaying posts 1,2,3 ?
Now the output of both taxonomies and categories and posts is carried out through the taxonomy template ( taxonomy-country.php )
As an option, the output of posts through the single-tur.php template , but then, as I understand it, the hierarchy is lost.
Answer the question
In order to leave comments, you need to log in
There is no such thing as a template for a list of terms. You can make a separate page and display what you got with get_terms
on it
+ take a look here, Theme File Hierarchy
When I register a post type that will require a custom template, I do it like this (Please note this is an exaggerated example that cannot contain all of these conditions, I added them only for demonstration, global($post) is also only needed to check the post type ):
add_filter('template_include', 'my_template');
function my_template( $template ) {
global $post;
if( $post->post_type == 'book' && is_page('portfolio') && is_category( array( 9, 'Без рубрики', 'php') ) ){
if ( $new_template = locate_template( array( 'page-portfolio.php' ) ) )
return $new_template ;
}
return $template;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question