您可以使用tax_query
, 请参见下面代码中的示例:
$args = array(
\'posts_per_page\' => 10,
\'post_type\' => \'product\',
\'post_status\' => \'publish\',
\'tax_query\' => array(
\'taxonomy\' => \'the_taxonomy_slug\', //the slug of the taxonomy you want to get
\'field\' => \'term_id\',
\'terms\' => $categories
)
);
请参见中的参考
Codex