【发布时间】:2018-05-17 17:58:12
【问题描述】:
我已将以下参数定义为我的查询的一部分:
$args = apply_filters('woocommerce_related_products_args', array(
'post_type' => 'product',
'author' => $artist,
'post_status' => 'publish',
'meta_query' => array(
array(
'key' => '_visibility',
'value' => array('catalog', 'visible'),
'compare' => 'IN'
)
)
) );
$products = new WP_Query( $args );
我需要从查询中排除一个名为 Magazines(slug “magazines”)或 ID 351 的类别。
我一直在尝试包含'category__not_in' => array('magazines'),所以它看起来像这样:
$args = apply_filters('woocommerce_related_products_args', array(
'post_type' => 'product',
'author' => $artist,
'post_status' => 'publish',
'category__not_in' => array('magazines'),
'meta_query' => array(
array(
'key' => '_visibility',
'value' => array('catalog', 'visible'),
'compare' => 'IN'
)
)
) );
$products = new WP_Query( $args );
但这似乎不起作用。
我在这里做错了什么?
【问题讨论】:
-
category__not_in 将 ARRAY 作为参数,将其设为 array('magazines') 并进行检查..!!
-
您好,更新了我的代码,但仍然无法为我工作..
标签: php wordpress woocommerce categories product