利用WP_Query
类,即tax_query
和fields
参数。从$found_posts
所有物请注意,这是示例代码。
$query = new WP_Query( [
\'post_type\' => \'games\',
\'tax_query\' = [
\'relation\' => \'AND\',
[
\'taxonomy\' => \'game_status\',
\'field\' => \'slug\',
\'terms\' => [ \'beaten\' ],
],
[
\'taxonomy\' => \'console\',
\'field\' => \'slug\',
\'terms\' => [ \'switch\' ],
]
],
\'fields\' => \'ids\',
] );
$count = $query->found_posts;