您可以使用WP API这样做:
$args = [
\'post_type\' => \'post\',
\'tax_query\' => [
\'relation\' => \'AND\',
[
\'taxonomy\' => \'your_taxonomy_name\',
\'field\' => \'slug\',
\'terms\' => array( \'arizona\', \'speech-language-pathology\' ),
]
],
];
$query = new WP_Query( $args );
然后您可以使用
$query
就像任何标准的post循环一样。
如果您只需要ID,可以使用fields
选项WP_Query
, 但请记住,您不会获得其他方式可能获得的所有缓存和性能好处,尤其是如果您要将ID传递到get_post
$args = [
\'post_type\' => \'post\',
\'tax_query\' => [
\'relation\' => \'AND\',
[
\'taxonomy\' => \'your_taxonomy_name\',
\'field\' => \'slug\',
\'terms\' => array( \'arizona\', \'speech-language-pathology\' ),
]
],
\'fields\' => \'ids\'
];
$query = new WP_Query( $args );
$posts = $query->get_posts(); // $posts is an array of post IDs