Answers for "woocommerce product page template name in php"

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 page template name in php"

Browse Popular Code Answers by Language