How can I achieve the following with the blade engine.
We have 3 levels of categories. And based in the level the category needs to have a different category template. I found a snippet on stack for classic WP themes. But this doesn’t work with the blade framework (which I’m quit new to).
Below you will find the code. Could you fellow roots friends help me out on this?
// Different template for subcategories
function fkm_subcategory_template( $template ) {
$cat = get_queried_object();
$children = get_terms( $cat->taxonomy, array(
'parent' => $cat->term_id,
'hide_empty' => false
) );
if( ! $children ) {
$template = locate_template( 'category-child.php' );
} elseif( 0 < $cat->category_parent ) {
$template = locate_template( 'category-grand-child.php' );
}
return $template;
}
add_filter( 'category_template', 'fkm_subcategory_template' );