簡體   English   中英

從 PHP 查詢中排除標簽

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM