我更喜欢使用数组形式。。。
$gabquery = new WP_Query(array(
\'post_type\'=>\'courses\',//The name of the post type
\'posts_per_page\'=>5, //Use this rather than showposts
\'tax_query\'=>array(
array(
\'taxonomy\'=>\'my-custom-tax\', //Your custom taxonomy name
\'operator\' => \'IN\',//NOT IN & AND also available
\'field\'=>\'slug\',//or you could select by ID
\'terms\'=>array(\'my-term-slug\')//Get posts with this term (or ID if above is ID)
)
)
));
以上查询类型为“courses”的帖子,将每页显示的帖子数量限制为5篇,并仅选择属于“my custom tax”分类法中“my term slug”术语的帖子。
看到了吗WP_Query Codex.