2011-07-29 31 views
0

我目前做如下選擇從自定義後類型職位,WordPress的幫助,選擇職位與query_post

query_posts('post_type=slideshow')

我需要以某種方式確保只有職位是回報,如果該分類「可用」返回NULL或者!=「移動」這是可能的嗎?

到目前爲止,我已經試過了,

query_posts('post_type=slideshow&not_in_category=14')

query_posts('post_type=slideshow&available=null')

,但無濟於事。我還能嘗試什麼?

回答

0

嘗試......

$post_type = "slideshow"; 
//your custom taxonomy name... 
$taxonomy = "available"; 
//put the term_id for the term "mobile" you want to exclude in an array 
$excluded_term_ids = array(1234); 

$args = array(
    "tax_query"=>array(
     array("taxonomy"=>$taxonomy, 
       "terms"=>$excluded_term_ids, 
       "field"=>"term_id", 
       "operator"=>"NOT IN" 
     ) 

    ), 
    "post_type"=>$post_type 
); 
$query = new WP_Query(); 
$posts = $query->query($args); 
var_dump($posts); 

我現在在做類似的事情與「高級搜索」在多個自定義分類,這似乎工作。您也可以查看wp-includes/query.php和wp-includes/taxonomy.php中的WP代碼。