Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_filter( 'body_class', 'custom_wc_product_cats_css_body_class' );
- function custom_wc_product_cats_css_body_class( $classes ){
- if ( is_singular( 'product' ) ) {
- $current_product = wc_get_product();
- $custom_terms = get_the_terms( $current_product->get_id(), 'product_cat' );
- if ( $custom_terms ) {
- foreach ( $custom_terms as $custom_term ) {
- $classes[] = 'product_cat-' . $custom_term->slug;
- }
- }
- }
- return $classes;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement