对于我的WC产品页面,我需要在body标签中添加一个类,以便我可以执行一些自定义样式.这是我为此创建的功能......
function my_add_woo_cat_class($classes) {
$wooCatIdForThisProduct = "?????"; //help!
// add 'class-name' to the $classes array
$classes[] = 'my-woo-cat-id-' . $wooCatIdForThisProduct;
// return the $classes array
return $classes;
}
//If we're showing a WC product page
if (is_product()) {
// Add specific CSS class by filter
add_filter('body_class','my_add_woo_cat_class');
}
Run Code Online (Sandbox Code Playgroud)
...但是如何获得WooCommerce猫咪ID?