2017-08-11 91 views
0

我試圖排除具有特定分類類別自定義後類型職位,但他們不斷顯示出來:WordPress的排除自定義分類類別從WP查詢

<?php 
$args = array(
'post_type' => 'info_link', 
'taxonomy' => 'linkcategory', 
'terms' => 'featured', 
'operator' => 'NOT IN', 
'orderby' => 'title', 
'order' => 'ASC', 
'posts_per_page' => '100', 
); 
query_posts($args); 
if (have_posts()) : while (have_posts()) : the_post(); 
... 
?> 

但是它不工作。我也嘗試過「不存在」作爲運營商,但他們仍然出現。我的錯誤在哪裏?

回答

1

答案是WP_Qurey documentation

$args = array(
    'post_type' => 'info_link', 
    'tax_query' => array(
     array(
      'taxonomy' => 'linkcategory', 
      'field' => 'slug', 
      'terms' => 'featured', 
      'operator' => 'NOT IN', 
     ), 
    ) 
); 
$query = new WP_Query($args); 
0

我認爲你必須使用下面

taxonomy__not_in => 'linkcategory' 
相關問題