下面是我最终如何解决这个问题的,并感谢Samuel指出了tax\\u查询,尽管这只是问题的一部分。我需要创建一个循环,我是这样做的:
$ones = get_terms( array(
\'taxonomy\' => \'ONE\',
\'hide_empty\' => false,
\'fields\' => \'id=>slug\'
) );
$fruits = get_terms( array(
\'taxonomy\' => \'FRUIT\',
\'hide_empty\' => false,
\'fields\' => \'id=>slug\'
) );
foreach ($fruits as $fruit) {
foreach ($ones as $one) {
$args = array(
\'post_type\' => \'my-post-type\',
\'post_status\'=>\'publish\',
\'tax_query\' => array(
\'relation\' => \'AND\',
array(
\'taxonomy\' => \'ONE\',
\'field\' => \'slug\',
\'terms\' => array( $one ),
),
array(
\'taxonomy\' => \'FRUIT\',
\'field\' => \'slug\',
\'terms\' => array( $fruit ),
),
),
);
$query = new WP_Query( $args );
echo $fruit .": " . $one . ": " . $query->post_count . "<br>";
}
}