WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Show a Div only if on Home Page (4 posts)

  1. bestfoot
    Member
    Posted 6 years ago #

    I have a wordpress site up and want to include a particular div only when on the main page. I use static front page option in the options settings.

    Can I in my page template with php say:
    if page is x, then display this?

  2. sasch9r
    Member
    Posted 6 years ago #

    Use the is_home() function and then it's easy.

    <?php
      if (is_home())
        echo '<div>bleh</div>';
    ?>

    Just a small example :P

  3. bestfoot
    Member
    Posted 6 years ago #

    does not appear to be working

    does the static front page option break the is_home bit?

  4. bestfoot
    Member
    Posted 6 years ago #

    got it ... this doesn't work for home page, only for posts ...

    see http://trac.wordpress.org/ticket/3682

    However the suggestion there:
    if_page(#) where number is the page that is set to your static page works

Topic Closed

This topic has been closed to new replies.

About this Topic