2011-07-29 33 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代码。