Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Exclude `Uncategorized` category from all terms lists.
- * @param array $terms [description]
- * @return array List of terms, less 1
- */
- function xx_exclude_terms_uncategorized( $terms ) {
- $exclude_terms = [ 1 ]; // Exclude `Uncategorized` category
- if ( ! empty( $terms ) && is_array( $terms ) ) {
- foreach ( $terms as $key => $term ) {
- if ( in_array( $term->term_id, $exclude_terms ) ) {
- unset( $terms[$key] );
- }
- }
- }
- return $terms;
- }
- add_filter( 'get_the_terms', 'xx_exclude_terms_uncategorized' );
Add Comment
Please, Sign In to add comment