我有一个新的WooCommerce(2.0.20)WordPress(3.8.1)网站使用Athena(1.0.17)主题 . 主页有一个最近的产品滑块 . 我有一个名为“文章”的产品类别,我不想在最近的产品滑块中显示 . 我认为我需要改变的代码是
$number_of_products = $settings['shop_area_entries'];
$args = array(
'post_type' => 'product',
'posts_per_page' => intval( $number_of_products ),
'meta_query' => array( array(
'key' => '_visibility',
'value' => array('catalog', 'visible'),
'compare' => 'IN'
))
);
$first_or_last = 'first';
$loop = new WP_Query( $args );
$query_count = $loop->post_count;
$count = 0;
任何人都可以告诉我如何更改$ args以便只在WP_Query中返回非“类别”类别的产品?
1 回答
在WP_Query Woocommerce products that belong in distinct multiple categories only tax_query的帮助下(不知道为什么我在第一次通过之前的问题时没有找到这个!)我发现我需要做的就是将我的args更改为:
如果我想添加更多类别,我只需要添加逗号分隔的目录slug列表 .