WordPress second-level classification wants to share a template file with first-level classification, how to write code?

WordPress second-level classification wants to share a template file with first-level classification. How do I write code?

make a judgment in category.php, but it doesn"t seem to work.

<?php

$post = $wp_query->post;

if(in_category("news")) {
    include(TEMPLATEPATH."/category-news.php");
}



else if (in_category("company")){
    include (TEMPLATEPATH."/category-news.php");
}



else {
    include(TEMPLATEPATH."/category-other.php");
}

?>

my company is a second-level category, and now I want to try the template of the first-level classification of category-news.php.

Mar.24,2021
Menu