在我的网站上,应该只显示产品的“商店”页面首先显示所有类别,然后是产品 .
我想从产品列表中删除类别 . 你可以在http://thehonestpet.com/shop/看到问题的一个例子
在商店页面上显示为产品的类别:
请指教?
我没有在WordPress中找到任何设置来解决这个问题 . 也许CSS修复?
以下工作,但只隐藏“商店”页面中的类别,但不隐藏产品类别页面...想法?
add_filter( 'get_terms', 'get_subcategory_terms', 10, 3 );
function get_subcategory_terms( $terms, $taxonomies, $args ) {
$new_terms = array();
// if a product category and on the shop page
if ( in_array( 'product_cat', $taxonomies ) && ! is_admin() && is_shop() ) {
foreach ( $terms as $key => $term ) {
if ( ! in_array( $term->slug, array( 'bedding', 'feeders-bowls', 'accessories', 'food', 'treats' ) ) ) {
$new_terms[] = $term;
}
}
$terms = $new_terms;
}
return $terms;
}
2 回答
WooCommerce产品类别显示在产品页面底部的添加到购物车按钮下方 .
您可以在主题functions.php中从产品摘要中删除 woocommerce_template_single_meta 操作,从布局中删除这些内容 .
像这样 :
这将从布局中删除类别aka product meta .
在function.php中添加此代码