这与已经添加的@Zach基本相同,但更聪明/不可读:)
$taxons = get_terms(
\'some_taxonomy\'
,array(
\'hide_empty\' => true // is the default
)
);
$count = count( $taxons );
$stack = array()
if ( 0 < $count)
{
// Catch all terms that have a count of "1"
// As we already have excluded all with
// a zero count are already excluded
$to_exclude = wp_list_filter(
$taxons
,array( \'count\' => 1 )
,\'AND\'
);
// fill our stack by filtering/diffing our 1-post taxons out
$stack = array_diff( (array) $taxons, (array) $to_exclude )
}
echo \'<pre>\'.var_export( $stack, true ).\'</pre>\';