Guest User

Untitled

a guest
Dec 17th, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. <?php
  2. /**
  3. * Exclude `Uncategorized` category from all terms lists.
  4. * @param array $terms [description]
  5. * @return array List of terms, less 1
  6. */
  7. function xx_exclude_terms_uncategorized( $terms ) {
  8. $exclude_terms = [ 1 ]; // Exclude `Uncategorized` category
  9. if ( ! empty( $terms ) && is_array( $terms ) ) {
  10. foreach ( $terms as $key => $term ) {
  11. if ( in_array( $term->term_id, $exclude_terms ) ) {
  12. unset( $terms[$key] );
  13. }
  14. }
  15. }
  16.  
  17. return $terms;
  18. }
  19. add_filter( 'get_the_terms', 'xx_exclude_terms_uncategorized' );
Add Comment
Please, Sign In to add comment