Support » Themes and Templates » how to make a div only appear on home page?

  • how would i manipulate this php code to get the div to only show on my homepage

    function my_div() {
    ?>
    <div id=”left” style=”left: 10px; top: 10px; width: 984px; height: 100px; background: black;”>
    </div>
    <?php
    }
    add_action(‘thesis_hook_after_header’ , ‘my_div’);

    any help is greatly appreciated

Viewing 4 replies - 1 through 4 (of 4 total)
  • By “homepage” do you mean the site front page, or the blog posts index? (In WordPress parlance, “home” refers to the blog posts index.)

    Assuming you mean the site front page, you need to wrap your code in an if ( is_front_page() ) conditional:

    <?php
    if ( is_front_page() ) {
        // stuff intended only for the front page goes here
    }
    ?>

    So, translating for your posted code:

    function my_div() {
        if ( is_front_page() ) {
            ?>
            <div id="left" style="left: 10px; top: 10px; width: 984px; height: 100px; background: black;">
            </div>
            <?php
        }
    }

    Thread Starter tyler_durdin

    (@tyler_durdin)

    omg it worked thank you so much i spent days trying to figure out how to apply that code lol

    it was so simple thank you so much

    Thread Starter tyler_durdin

    (@tyler_durdin)

    while your here could you tell me how to add a custom background image in thesis 1.8?

    the guide they have on their forum doesn’t work

    it was so simple thank you so much

    Glad it worked. 🙂

    while your here could you tell me how to add a custom background image in thesis 1.8?

    Sorry; you’ll have to consult DIY Themes for Thesis-specific support, as it is a commercial Theme.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘how to make a div only appear on home page?’ is closed to new replies.