首页 文章

Woocommerce从相关产品中排除特定类别的产品

提问于
浏览
0

我试图从内容单品页面上的相关产品中排除两个特定类别(精美 Watch ,高级珠宝)的产品 . 我偶然发现的最接近的想法是来自woocommerce \ template \ single-product \中名为related.php的文件中的代码:

$args = apply_filters('woocommerce_related_products_args', array(
'post_type'     => 'product',
'ignore_sticky_posts'   => 1,
'no_found_rows'     => 1,
'posts_per_page'    => $posts_per_page,
'orderby'       => $orderby,
'post__in'      => $related,
'post__not_in'      => array($product->id)
 ) );

知道如何修改这段代码或者我看错了什么?

1 回答

  • 0

    你应该使用

    'post__not_in'      => array($product->id)
    

相关问题