0
votes

I am using WordPress CPT CPT name is - cars For this CPT i have Taxonomy - carstype In carstype i create category's type1 type2

Now i want that type1 have it template and type 2 its

If i use single-cars.php this will be same for both type1 and type2 , how make individually templates for it https://developer.wordpress.org/themes/basics/template-hierarchy/

1

1 Answers

0
votes

Use single-cars.php as single page template for cars. You can put check in single-cars.php

if( has_term( 1 ) ){
get_template_part(); //Template for type 1
}
elseif( has_term( 2 ) ){
get_template_part(); //Template for type 2
}
else{
get_template_part(); //Template for all other types
}