我们对类型和品牌使用WooCommerce产品类别,但是希望从相关产品中删除类型类别并仅显示相同品牌的类别 .
我们发现这个解决方案
function exclude_brands_from_related( $categories ){
// array of category id's that should be excluded
$exclude_cats = array( '100', '101', '102');
foreach( $categories as $index => $cat ){
if( in_array( $cat->term_id, $exclude_cats ) ){
unset($categories[$index]);
}
}
return $categories;
}
add_filter( 'woocommerce_get_related_product_cat_terms', 'exclude_brands_from_related' );
但它不适用于WooCommerce 3.2 .
任何帮助将不胜感激!