Hello @mariodts!
To add css only on product categories and subcategories, you will need to add a piece of code to your theme’s functions.php file.
// add taxonomy term to body_class
function woo_custom_taxonomy_in_body_class( $classes ){
if( is_singular( 'product' ) )
{
$custom_terms = get_the_terms(0, 'product_cat');
if ($custom_terms) {
foreach ($custom_terms as $custom_term) {
$classes[] = 'product_cat_' . $custom_term->slug;
}
}
}
return $classes;
}
add_filter( 'body_class', 'woo_custom_taxonomy_in_body_class' );
The CSS class to target would be product_cat_SLUG
, where SLUG
is changed with the category slug.The slug can be found by viewing the categories under Products > Categories, they are lower case with spaces replaced with dashes.
![https://cld.wthms.co/obYueF](https://cld.wthms.co/obYueF+)
Image link: https://cld.wthms.co/obYueF
Hopefully you will find that helpful. ??
All the best,