Title: Insert &lt;div&gt; in PHP code
Last modified: August 19, 2016

---

# Insert <div> in PHP code

 *  Resolved Anonymous User 303747
 * (@anonymized-303747)
 * [16 years, 7 months ago](https://wordpress.org/support/topic/insert-ltdivgt-in-php-code/)
 * This should be an easy one – but I keep getting PHP errors. Maybe someone will
   have a quick fix for this.
 * I have the following code, which is intended to display a taxonomy term description
   at the bottom of single.php
 *     ```
       <?php $terms = get_the_terms( $post->ID , 'taxonomy-name' );
       if($terms) {
       	foreach( $terms as $term ) {
       		echo $term->description.'<br />';
       	}
       }
       ?>
       ```
   
 * Works like a champ. Now I would like to wrap the echoed description in a DIV 
   so I can style it. I’d like to make it part of the PHP query so I won’t see an
   empty DIV when this post has no terms.
 * Any ideas?

Viewing 1 replies (of 1 total)

 *  Thread Starter Anonymous User 303747
 * (@anonymized-303747)
 * [16 years, 7 months ago](https://wordpress.org/support/topic/insert-ltdivgt-in-php-code/#post-1275400)
 * The best questions are the ones you figure out yourself 🙂
 *     ```
       <?php $terms = get_the_terms( $post->ID , 'taxonomy-name' );
       	if($terms) {
       	foreach( $terms as $term ) {
       	echo '<div class="class-name">'
              .$term->description.'<br /></div>';
       		}
       	}
       ?>
       ```
   
 * works for me.

Viewing 1 replies (of 1 total)

The topic ‘Insert <div> in PHP code’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 1 participant
 * Last reply from: Anonymous User 303747
 * Last activity: [16 years, 7 months ago](https://wordpress.org/support/topic/insert-ltdivgt-in-php-code/#post-1275400)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
