Title: Hide Empty Taxonomy
Last modified: August 31, 2016

---

# Hide Empty Taxonomy

 *  Resolved [WebStyley](https://wordpress.org/support/users/webstyley/)
 * (@webstyley)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/hide-empty-taxonomy/)
 * Hello, I am using the below code to display taxonomies on a page template. The
   taxonomies are displaying, but they are not hiding the empty terms (no content
   associated with the taxonomy). Any ideas on how to hide empty terms with the 
   below code, or even a different code? Thanks
 *     ```
       <?php
   
       $args = array( 'hide_empty=1', 'hierarchical=1' );
   
       $terms = get_terms( 'service-area', $args );
       if ( ! empty( $terms ) && ! is_wp_error( $terms ) ) {
           $count = count( $terms );
           $i = 0;
           $term_list = '<p class="my_term-archive">';
           foreach ( $terms as $term ) {
               $i++;
               $term_list .= '<a href="' . esc_url( get_term_link( $term ) ) . '" alt="' . esc_attr( sprintf( __( 'View all post filed under %s', 'my_localization_domain' ), $term->name ) ) . '">' . $term->name . '</a>';
               if ( $count != $i ) {
                   $term_list .= ', ';
               }
               else {
                   $term_list .= '</p>';
               }
           }
           echo $term_list;
       }
       ?>
       ```
   

Viewing 4 replies - 1 through 4 (of 4 total)

 *  [AJ Mallory](https://wordpress.org/support/users/jasonm4563/)
 * (@jasonm4563)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/hide-empty-taxonomy/#post-7183638)
 * Hey WebStyley,
 * I think your issue is a typo on the first line of your code snippet. Try `$args
   = array( 'hide_empty' = 1, 'hierarchical' = 1 );`
 * Hope that resolves it for you!
    –AJ
 *  Thread Starter [WebStyley](https://wordpress.org/support/users/webstyley/)
 * (@webstyley)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/hide-empty-taxonomy/#post-7183641)
 * AJ thanks for the reply. That change gives me a 500 error? Any other ideas on
   how to hide empty taxonomies.
 *  [AJ Mallory](https://wordpress.org/support/users/jasonm4563/)
 * (@jasonm4563)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/hide-empty-taxonomy/#post-7183661)
 * WebStyley, yes try this:
 * `$args = array( 'hide_empty' => 1, 'hierarchical' => 1 );`
 * Sorry I didn’t get the syntax correct the first time though.
 * –AJ
 *  Thread Starter [WebStyley](https://wordpress.org/support/users/webstyley/)
 * (@webstyley)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/hide-empty-taxonomy/#post-7183800)
 * Thank you.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Hide Empty Taxonomy’ is closed to new replies.

## Tags

 * [taxonomy](https://wordpress.org/support/topic-tag/taxonomy/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 4 replies
 * 2 participants
 * Last reply from: [WebStyley](https://wordpress.org/support/users/webstyley/)
 * Last activity: [10 years, 1 month ago](https://wordpress.org/support/topic/hide-empty-taxonomy/#post-7183800)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
