I am using this function to filter category terms from a calendar:

  $terms = get_terms( TribeEvents::TAXONOMY, array( 'orderby' => 'name', 'order' => 'ASC','exclude' => array(77)) );

  echo '<li>Category:</li>';
  foreach ( $terms as $term ) {
    echo '<li><a href="'.$url.'?tribe_eventcategory='.$term->term_taxonomy_id.'">'.$term->name.'</a></li>';
  }

I need to exclude event category ID 71 too. How can I do that?

1 Answer
1

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

$terms = get_terms( TribeEvents::TAXONOMY, array( 
                        'orderby' => 'name',
                        'order'   => 'ASC',
                        'exclude' => array( 77, 71 ),
) );

echo '<li>Category:</li>';
foreach ( $terms as $term ) {
    echo '<li><a href="'.$url.'?tribe_eventcategory='.$term->term_taxonomy_id.'">'.$term->name.'</a></li>';
}

Leave a Reply

Your email address will not be published. Required fields are marked *