Forums

Include html on wordpress main index page only? (4 posts)

  1. islanddesign
    Member
    Posted 3 years ago #

    I'm new to wordpress, so forgive me if this is really basic.

    I'd like to use some sort of conditional to use a different template or a conditional to include blocks of html on the main wordpress index page only (but not on any other wordpress sub-pages.)

    The idea is that I want to integrate wordpress with an existing website and to retain some existing static homepage elements that tie in with others parts of the site, but use wordpress to maintain news items on the site, and have these news items appear on the index. Everything else on the index can be simply included as static html if I can figure out how to do this with wordpress for the main index page only.

    Is there an easy way to do this?

    Many thanks.

  2. gornik321
    Member
    Posted 3 years ago #

    you can write this:
    <?php
    if (is_home()){
    ?>

    your html code here

    <?php
    }
    ?>
    is_home function checks if you are on index.php page

  3. Jaycos
    Member
    Posted 3 years ago #

    I use this on my theme's index.php:
    <?php if (is_home() && ($paged <= "1"))
    { ?>
    ...

  4. islanddesign
    Member
    Posted 3 years ago #

    Many thanks to both of you! This works great!

Topic Closed

This topic has been closed to new replies.

About this Topic