Title: Adding PHP to a DIV
Last modified: August 30, 2016

---

# Adding PHP to a DIV

 *  [ReinoutSch](https://wordpress.org/support/users/reinoutsch/)
 * (@reinoutsch)
 * [11 years ago](https://wordpress.org/support/topic/adding-php-to-a-div/)
 * This might be a stupid question but I just can’t figure it out. I want to add
   some PHP to a DIV inside my custom theme. Everytime I add the code inside a DIV
   it jumps out.
 * Link to page:
    [http://reinowo58.fiftyeight.axc.nl/hoe/](http://reinowo58.fiftyeight.axc.nl/hoe/)
 * As you can see on the right side there are 2 divs. I added a piece of PHP to 
   the container that grabs the latest post. But it appears outside the DIV.
 * This is the code:
 *     ```
       <div style="width: 250px; height: 325px; background-color: #ebecec; border-radius: 25px; padding: 25px;">
       <div style="width: 170px; height: 40px; background-color: #fb3099; border-radius: 18px; margin-left: auto; margin-right: auto; text-align: center;">
       <h2 style="padding-top: 14px;">NIEUWS</h2>
       </div>
       [insert_php] query_posts('showposts=1'); [/insert_php]
       [insert_php] while (have_posts()) : the_post(); [/insert_php]
       [insert_php] endwhile;[/insert_php]
   
       </div>
       ```
   
 * As you can see on the page the text is on the bottom of the page instead of inside
   the DIV. Please help me out with this one.
 * [https://wordpress.org/plugins/insert-php/](https://wordpress.org/plugins/insert-php/)

Viewing 1 replies (of 1 total)

 *  [WillBontrager](https://wordpress.org/support/users/willbontrager/)
 * (@willbontrager)
 * [11 years ago](https://wordpress.org/support/topic/adding-php-to-a-div/#post-6190655)
 * Hi,
 * Two things.
 * 1.
    For a theme template, use regular PHP with its start-end tags <?php and ?
   > instead of Insert PHP with its [insert_php] and [/insert_php] tags. Use Insert
   PHP only for posts and pages.
 * 2.
    For future reference, if you do decide to use Insert PHP within your posts
   and pages, read the [http://www.willmaster.com/software/WPplugins/insert-php-wordpress-plugin-instructions.php](http://www.willmaster.com/software/WPplugins/insert-php-wordpress-plugin-instructions.php)
   page for special things to look out for. As an example, the way you have it in
   your theme template wouldn’t work in a post or page because all the code would
   need to be within one set of [insert_php] … [/insert_php] tags, not broken up
   into three sets.
 * Have a wonderful June!
 * Will

Viewing 1 replies (of 1 total)

The topic ‘Adding PHP to a DIV’ is closed to new replies.

 * ![](https://ps.w.org/insert-php/assets/icon-256x256.gif?rev=3523853)
 * [Woody Code Snippets – Insert PHP, CSS, JS, and Header/Footer Scripts](https://wordpress.org/plugins/insert-php/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/insert-php/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/insert-php/)
 * [Active Topics](https://wordpress.org/support/plugin/insert-php/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/insert-php/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/insert-php/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [WillBontrager](https://wordpress.org/support/users/willbontrager/)
 * Last activity: [11 years ago](https://wordpress.org/support/topic/adding-php-to-a-div/#post-6190655)
 * Status: not resolved