从PHP查询中排除标记

从PHP查询中排除标记,php,wordpress,Php,Wordpress,我在我的子主题functions.php文件中编写了以下查询 目前,这项工作完全符合它的需要,但是我希望扩展此查询,以便它排除特定的标记 'post_type' => 'product', 'meta_key' => 'total_sales', 'orderby' => 'meta_value_num', 'posts_per_page' => 10, 'tax_query' => array( array(

我在我的子主题
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',
      ),
   ),
); 

您可以在“中使用“比较”=>“不”

'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'
    ),
),
有用的链接


Hi@Bhautik,因此该产品同时具有492和422标签ID,但我希望从查询中排除任何具有422标签ID的产品。您能否修改您的代码以反映这一点,并请详细说明您的更改?