Title: Conditional for term_description()
Last modified: August 20, 2016

---

# Conditional for term_description()

 *  [Pete](https://wordpress.org/support/users/perthmetro/)
 * (@perthmetro)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/conditional-for-term_description/)
 * I have this template file (taxonomy-xyz.php), as it shows each tag/term I’d also
   like to show the term decription BUT only if the tag/term has a description.
 * Thanks

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

 *  Moderator [keesiemeijer](https://wordpress.org/support/users/keesiemeijer/)
 * (@keesiemeijer)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/conditional-for-term_description/#post-2925839)
 * Try it with this:
 *     ```
       <?php
       $description  = term_description();
       if ( ! empty( $description ) ){
         // there is a term description
         echo $description;
       }
       ?>
       ```
   
 * [http://codex.wordpress.org/Function_Reference/term_description](http://codex.wordpress.org/Function_Reference/term_description)
 *  Thread Starter [Pete](https://wordpress.org/support/users/perthmetro/)
 * (@perthmetro)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/conditional-for-term_description/#post-2925848)
 * Thanks for that, works great… can I ask how I’d prefix this with some html (that
   also only shows if the term description is present.
 * Cheers,
    Pete
 *  Moderator [keesiemeijer](https://wordpress.org/support/users/keesiemeijer/)
 * (@keesiemeijer)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/conditional-for-term_description/#post-2925850)
 * Because `term_description()` wraps the description in a paragraph I changed the
   code a little so you can use your own html. in this example I wrapped the description
   in a h1:
 *     ```
       <?php
       $description  =  get_queried_object()->description;
       if ( ! empty( $description ) ) : ?>
       <!-- html here -->
       <h1>
       <?php echo $description; ?>
       </h1>
       <?php endif; ?>
       ```
   
 *  Thread Starter [Pete](https://wordpress.org/support/users/perthmetro/)
 * (@perthmetro)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/conditional-for-term_description/#post-2925851)
 * That’s great.. thanks so much. A useful little piece of code that!
 *  Moderator [keesiemeijer](https://wordpress.org/support/users/keesiemeijer/)
 * (@keesiemeijer)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/conditional-for-term_description/#post-2925854)
 * You’re welcome. Glad you got it resolved.

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

The topic ‘Conditional for term_description()’ is closed to new replies.

## Tags

 * [conditional](https://wordpress.org/support/topic-tag/conditional/)
 * [custom taxonomy](https://wordpress.org/support/topic-tag/custom-taxonomy/)
 * [else](https://wordpress.org/support/topic-tag/else/)
 * [if](https://wordpress.org/support/topic-tag/if/)
 * [tag](https://wordpress.org/support/topic-tag/tag/)
 * [term](https://wordpress.org/support/topic-tag/term/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 5 replies
 * 2 participants
 * Last reply from: [keesiemeijer](https://wordpress.org/support/users/keesiemeijer/)
 * Last activity: [13 years, 10 months ago](https://wordpress.org/support/topic/conditional-for-term_description/#post-2925854)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
