我的代码如下。使用条款删除是行不通的。我需要它像这样工作而不是按 ID 删除。
$terms = get_terms( 'MY_TAXONOMY', array(
'orderby' => 'name',
'order' => 'ASC',
'exclude' => array(),
) );
$exclude = array("MY TERM", "MY TERM 2", "MY TERM 3");
$new_the_category = '';
foreach ( $terms as $term ) {
if (!in_array($term->term_name, $exclude)) {
$new_the_category .= '<div class="post hvr-grow"><li><strong><a id="lista" href="'.esc_url( get_term_link( $term ) ) .'">'.$term->name.'</a>'. ' ('. $term->count . ')</strong></li></div>';
}
}
echo substr($new_the_category, 0);