WordPress: How to show a div on only certain pages

Here is the code you can use to show a

on only the pages that you want it to be shown on:

<code><?php if( is_page(home) ) { ?> 
<div> This is the div that will only show up on the page named 'Home' </div> 
<?php } ?></code>

You can also have it show up on every page except for a particular page:

<code><?php if( !is_page(home) ) { ?>
<div> This is the div that will only show up any page that is NOT named 'Home' </div> 
<?php } ?></code>

Let me know if you have any questions or trouble with this at all.

Meet the author

Libby Fisher is an experienced freelance web developer, recently relocated from Seattle to Boston, and passionate about developing websites that are both aesthetically appealing and intuitively usable - or as she prefers: "beautifully effective."

  • John

    Hi Libby, what if I want only to show it to home, about-us and contact-us. What will be the code?