Title: div within php tags
Last modified: August 20, 2016

---

# div within php tags

 *  Resolved [pietergoosen](https://wordpress.org/support/users/pietergoosen/)
 * (@pietergoosen)
 * [13 years, 5 months ago](https://wordpress.org/support/topic/div-within-php-tags/)
 * Hi there
 * I would like to put a div around the folowing part switch ( $list_style ) {} 
   in the code below
 *     ```
       <?php endif;
       while ( $wp_query->have_posts() ) :
       $wp_query->the_post();
   
       switch ( $list_style ) {very long coding, in short get_post_format or custom post formats}
       endwhile;
       else : ?>
       ```
   
 * Any ideas. I did try to echo it outside the php tag, but it is not working. I’m
   still learning wordpress, so any help will be appreciated.
 * Many thank

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

 *  [kevinhaig](https://wordpress.org/support/users/kevinhaig/)
 * (@kevinhaig)
 * [13 years, 5 months ago](https://wordpress.org/support/topic/div-within-php-tags/#post-3212976)
 * Try this :
 *     ```
       <?php endif;
       while ( $wp_query->have_posts() ) :
       $wp_query->the_post();
       echo '<div class="your-class">';
       switch ( $list_style ) {very long coding, in short get_post_format or custom post formats}
       echo '</div>';
       endwhile;
       else : ?>
       ```
   
 *  Thread Starter [pietergoosen](https://wordpress.org/support/users/pietergoosen/)
 * (@pietergoosen)
 * [13 years, 5 months ago](https://wordpress.org/support/topic/div-within-php-tags/#post-3212986)
 * Hi kevin
 * Many thanks for you solution. Works perfectly. Now I can start to work on the
   css grid. Again, many thanks

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

The topic ‘div within php tags’ is closed to new replies.

## Tags

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

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 2 participants
 * Last reply from: [pietergoosen](https://wordpress.org/support/users/pietergoosen/)
 * Last activity: [13 years, 5 months ago](https://wordpress.org/support/topic/div-within-php-tags/#post-3212986)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
