4

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?

2
  • Is the term with ID 71 part of the TribeEvents::TAXONOMY or is it a term under the standard category taxonomy? Oct 18 '16 at 19:28
  • I am not sure, What you mean but we need to remove the category with id 71 just same as we did with category with id 77. Oct 18 '16 at 21:24
8

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>';
}
1
  • 1
    Thank you, I have tried the same by due to typo it was missing one closing bracket. It's fixed thank you :) Oct 18 '16 at 21:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.