Title: PHP-coding help: how to exclude and include divs
Last modified: August 21, 2016

---

# PHP-coding help: how to exclude and include divs

 *  Resolved [dekraan](https://wordpress.org/support/users/dekraan/)
 * (@dekraan)
 * [12 years, 7 months ago](https://wordpress.org/support/topic/php-coding-help-how-to-exclude-and-include-divs/)
 * Hi there!
 * I have one div, that I want to appear on my homepage, and another div that should
   only appear on the other pages in the same location.
 * I’ve got the first part right with the following code, but I don’t know how to
   get the other div when I am not on home:
 * `
    <?php if (is_home()) echo ‘<div id=”whitepaper”><h2 class=”description”>text
   </h2></div>’; ?>

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

 *  [Andrew Nevins](https://wordpress.org/support/users/anevins/)
 * (@anevins)
 * WCLDN 2018 Contributor | Volunteer support
 * [12 years, 7 months ago](https://wordpress.org/support/topic/php-coding-help-how-to-exclude-and-include-divs/#post-4216225)
 * Look at using an “`else`” statement along with your “`if`“
    [http://www.w3schools.com/php/php_if_else.asp](http://www.w3schools.com/php/php_if_else.asp)
 *  Thread Starter [dekraan](https://wordpress.org/support/users/dekraan/)
 * (@dekraan)
 * [12 years, 7 months ago](https://wordpress.org/support/topic/php-coding-help-how-to-exclude-and-include-divs/#post-4216259)
 * Hi Andrew,
 * thank you for the link. I don’t really know that much of what I am doing, and
   I noticed the examples there have the echo part between { and }. In my (working)
   code, it is not. How should I arrange this?
 * Just by looking at w3schools I thought something like:
 *     ```
       <?php
       if (is_home())
       echo '<div id="home">text</div>';
       else
       {
       echo '<div id="other">text></div>';
       }
       ?>
       ```
   
 *  [Andrew Nevins](https://wordpress.org/support/users/anevins/)
 * (@anevins)
 * WCLDN 2018 Contributor | Volunteer support
 * [12 years, 7 months ago](https://wordpress.org/support/topic/php-coding-help-how-to-exclude-and-include-divs/#post-4216261)
 * >  How should I arrange this?
 * To make the code easier to read you should use those curly braces to wrap code
   inside “`if`” and “`else`” statements.
 * For example,
 *     ```
       <?php
       if ( is_home() ) {
        echo '<div id="home">text</div>';
       }
       else {
        echo '<div id="other">text></div>';
       }
       ?
       ```
   
 * Does that help?
 *  Thread Starter [dekraan](https://wordpress.org/support/users/dekraan/)
 * (@dekraan)
 * [12 years, 7 months ago](https://wordpress.org/support/topic/php-coding-help-how-to-exclude-and-include-divs/#post-4216293)
 * Hi Andrew,
 * yes it does, very much. I thought at first that it made my site disappear, but
   that is because you missed a > at the end. Now it works great! And I’ve learnt
   something about those braces and if and else. Couldn’t be better! A sunday well
   spent, even if this is the only thing I do 🙂

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

The topic ‘PHP-coding help: how to exclude and include divs’ is closed to new replies.

## Tags

 * [class](https://wordpress.org/support/topic-tag/class/)
 * [div](https://wordpress.org/support/topic-tag/div/)
 * [id](https://wordpress.org/support/topic-tag/id/)
 * [if](https://wordpress.org/support/topic-tag/if/)
 * [php](https://wordpress.org/support/topic-tag/php/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 4 replies
 * 2 participants
 * Last reply from: [dekraan](https://wordpress.org/support/users/dekraan/)
 * Last activity: [12 years, 7 months ago](https://wordpress.org/support/topic/php-coding-help-how-to-exclude-and-include-divs/#post-4216293)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
