Exclude multiple terms using get_terms() function

Soution for : exclude multiple terms using get_terms() function

With get_terms(), the exclude parameter takes an array of term IDs, so just add the second term to the array:

1
2
3
4
5
6
7
8
9
10
11
$terms = get_terms( 'product_cat', array(
    'orderby'    => 'name',
    'order'      => 'ASC',
    'hide_empty' => 0,
    'exclude' => array( 23 ),
    ));
 
echo '<li>Category:</li>';
foreach ( $terms as $term ) {
    echo '<li><a href="#">'.$term->name.'</a></li>';
}

No comments:

Post a Comment