Answers for "woocommerce product template based on category"

1

is product category woocommerce

if( is_product_category() ) {
	// yay, we are on a product category page!
} else {
 
}
Posted by: Guest on October-30-2020
0

woocommerce create product specific template

add_filter('body_class','wpa76627_class_names');
function wpa76627_class_names( $classes ) {
    if( is_singular( 'product' ) ):
        global $post;
        foreach( get_the_terms( $post->ID, 'product_cat' ) as $cat )
            // maybe you want to make this more unique, like:
            // $classes[] = 'product-category-' . $cat->slug;
            $classes[] = $cat->slug;
    endif;
    return $classes;
}
Posted by: Guest on April-13-2021

Code answers related to "woocommerce product template based on category"

Browse Popular Code Answers by Language