[英]Exclude Tags from PHP Query
我在我的子主题functions.php
文件中编写了以下查询。
目前这完全符合它的需要,但是我希望扩展这个查询,以便它排除特定的标签。
'post_type' => 'product',
'meta_key' => 'total_sales',
'orderby' => 'meta_value_num',
'posts_per_page' => 10,
'tax_query' => array(
array(
'taxonomy' => 'product_tag',
'terms' => 492,
'field' => 'id',
),
),
);
您可以使用'compare' => 'NOT IN'
。
'post_type' => 'product',
'meta_key' => 'total_sales',
'orderby' => 'meta_value_num',
'posts_per_page' => 10,
'tax_query' => array(
array(
'taxonomy' => 'product_tag',
'terms' => array( 492, 422 ),
'field' => 'id',
'compare' => 'NOT IN'
),
),
有用的链接
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.