One simple way to use different layout for child and parent terms is to check, if the current queried object has parent or not and then include the right template part based on a if statement. For example like this,
// in your taxonomy/term template file
$current_term = get_queried_object();
// parent property is either 0 or the parent ID
if ( $current_term->parent ) {
get_template_part( 'term-child-template' );
} else {
get_template_part( 'term-parent-template' );
}
I haven't tested the following example, but you could probably use template_include
filter also to switch templates, if the current object is a child or parent term.
function child_or_parent_taxonomy_template( $template ) {
$current_object = get_queried_object();
if ( is_a( $current_object, 'WP_Term' ) ) {
$term_template = $current_tax->parent ? 'child' : 'parent';
$term_template = locate_template( array( "term-{$term_template}-template.php" ) ); // update as per your setup
if ( '' !== $term_template ) {
return $term_template;
}
}
return $template;
}
add_filter( 'template_include', 'child_or_parent_taxonomy_template', 99 );