How to target parent product category and its children using WooCommerce?
the WordPress function cat_is_ancestor_of() is made for WordPress categories, but not for WooCommerce product categories which is a custom taxonomy product_cat. For Custom taxonomies you can use WordPress term_is_ancestor_of() function like: term_is_ancestor_of( 19, get_queried_object_id(), ‘product_cat’ ) So in your code: if ( is_product_category( ‘foo-category’ ) || term_is_ancestor_of( 19, get_queried_object_id(), ‘product_cat’ ) ) { wc_get_template( ‘archive-foo.php’ … Read more