【发布时间】:2020-01-31 17:53:24
【问题描述】:
我想删除我们商店中的显式标签。 一般也没有问题。 但是:我想把它归为一类(ID = 15)
我发现这段代码可以删除特殊页面上的标签
现在需要改变什么?
add_filter( 'woocommerce_product_tabs', 'conditionaly_removing_product_tabs', 99 );
function conditionaly_removing_product_tabs( $tabs ) {
// Get the global product object
global $product;
// Get the current product ID
$product_id = method_exists( $product, 'get_id' ) ? $product->get_id() : $product->id;
// Define HERE your targeted categories (Ids, slugs or names) <=== <=== <===
$product_cats = array( 'clothing', 'posters' );
// If the current product have the same ID than one of the defined IDs in your array,…
// we remove the tab.
if( has_term( $product_cats, 'product_cat', $product_id ) ){
// KEEP BELOW ONLY THE TABS YOU NEED TO REMOVE <=== <=== <=== <===
unset( $tabs['description'] ); // (Description tab)
unset( $tabs['reviews'] ); // (Reviews tab)
unset( $tabs['additional_information'] ); // (Additional information tab)
}
return $tabs;
}```
【问题讨论】:
-
类别 id = 15 的名称是什么??
-
name="请求"