Answer the question
In order to leave comments, you need to log in
How to apply a template to subcategories?
At the moment, the template only applies to the parent category, how can I apply it to all descendants of this category?
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
// Get current category slug
global $wp_query;
$cat_slug = $wp_query->query_vars['product_cat'];
// Call template conditionally
if($cat_slug == 'zakaznaya-produktsiya') {
wc_get_template( 'archive-custom.php' );
} else {
wc_get_template( 'archive-product.php' );
}
?>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question