My code below. It does not work to delete using the terms. I need it to work like this and not delete by 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);
Your code is working fine just need to replace $term->term_name to $term->name then it should work fine. see below code for reference.
$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->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);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With