📌  相关文章
📜  woocommerce 创建产品特定模板 - 任何代码示例

📅  最后修改于: 2022-03-11 14:56:02.487000             🧑  作者: Mango

代码示例1
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;
}