WordPress.org

Support

Support » How-To and Troubleshooting » Exclude "header" from home page

Exclude "header" from home page

  • I have a header callout area for an opt-in form on my site, but I need it to appear above every page EXCEPT the home page. How can I set the home page to not have this opt-in area without manually going in and adding the code to each and every page I DO want it on?

    The site is claritymind.com, but I have taken the opt-in area down for now as it isn’t doing what I want.

    Thanks!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Christine Rondeau

    @crondeau

    Volunteer Forum Moderator

    What you want to do is use a conditional statement in the header area.

    So something like:

    <?php if(is_front_page()) {?>
     Do this....
    <?php } else { ?>
    Do that
    <?php } ?>

    Thank you for a quick response! I am very very new to PHP, so is it possible to have something like

    <?php if(is_front_page()) {?>
    Do Nothing!
    <?php } else { ?>
    Do that…
    <?php } ?>

    The home page is exactly the way I want, so I don’t want anything to happen on it. I just need the opt-in to show at the top of all the other pages.

    Just answered my own question with this:

    <?php if(is_front_page()) {?>
    <?php } else { ?>
    (opt-in code)
    <?php } ?>

    Thanks so much!

    Christine Rondeau

    @crondeau

    Volunteer Forum Moderator

    Indeed that would work.

    Another option is:

    <?php if(!is_front_page()) {?>
    (opt-in code)
    <?php } ?>

    The exclamation mark means if this is NOT the home page, then insert the opt-in code.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Exclude "header" from home page’ is closed to new replies.
Skip to toolbar