我从一个类似的问题中总结出了这一点。如果其他人需要:
<?php
$terms = get_terms( array(
\'taxonomy\' => \'features\',
\'hide_empty\' => false
) );
if (!empty($terms) && ! is_wp_error( $terms )) {
echo \'<section>\';
foreach ($terms as $term) {
$class = has_term( $term->term_id, \'features\' ) ? \'active\' : \'unassigned\';
echo \'<div class="term \' . $class . \'"><h6>\' . $term->name . \'</h6>\';
echo \'<div class="availability"></div>\';
echo \'<p>\'.$term->description.\'</p></div>\';
}
echo \'</section>\';
} ?>