[resolved] If is homepage (5 posts)

  1. stipto
    Posted 5 years ago #

    Hello there,

    Simple but unable to crack this one: How to display a few div's only on the homepage? I've tried a lot of solutions, none worked for me.
    I'm doing this the header.php of the theme:

    <?php if( is_home() ) : ?>
    <div align="center">
    <div class="trigger"><h1><?php echo trigger($bowling); ?></h1><br /><h3>Wanna go bowling? Push the <a href="/bowling">Button</a></h3></div>
    <div class="cleardiv"></div>
    <?php endif;?>

    Doesn't work... Anyone?

  2. c.e.macht
    Posted 5 years ago #


    works fine for me (apart from the trigger($bowling); obviously). What happens right now? Does it display on any/every page?

  3. Tim Moore

    Posted 5 years ago #

    is_home() works on your home page only if it is set to show your posts. If you have a static front page set, use is_front_page().

  4. stipto
    Posted 5 years ago #


    I'm using is_front_page() now but it shows up on every page. Maybe because I put it in header.php? But that's where I want it, above the body and below the menu...

  5. stipto
    Posted 5 years ago #

    I solved it, put it in another php file and works fine now without the if statement.

Topic Closed

This topic has been closed to new replies.

About this Topic