WordPress.org

Ready to get started?Download WordPress

Forums

Exclude "header" from home page (5 posts)

  1. squidpeg
    Member
    Posted 1 year ago #

    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!

  2. 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 } ?>
  3. squidpeg
    Member
    Posted 1 year ago #

    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.

  4. squidpeg
    Member
    Posted 1 year ago #

    Just answered my own question with this:

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

    Thanks so much!

  5. 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.

Topic Closed

This topic has been closed to new replies.

About this Topic