Answer the question
In order to leave comments, you need to log in
How to assign a template to a child category?
I don't know how to assign a template for a child category page on woocommerce (by default, both the main and the child page use the archive-product.php template). We need a cycle that could determine that the category is a child and substitute a custom template for it.
Answer the question
In order to leave comments, you need to log in
As a result, I made a compromise: since there will be a fixed number of parent categories, I decided to assign an arbitrary template to them by default, archive-product.php is assigned to the children by default.
The code was inserted into taxonomy-product-cat.php
if (is_product_category( 'cat' )|| is_product_category( 'dog')|| is_product_category( 'fish')|| is_product_category( 'bird')|| is_product_category( 'reptile')|| is_product_category( 'rodent') ){ wc_get_template( 'parentcat.php' );
}
else { wc_get_template( 'archive-product.php' );
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question