Forums

how to make a div only appear on home page? (5 posts)

  1. tyler_durdin
    Member
    Posted 11 months ago #

    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

  2. Chip Bennett
    Member
    Posted 11 months ago #

    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
        }
    }
  3. tyler_durdin
    Member
    Posted 11 months ago #

    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

  4. tyler_durdin
    Member
    Posted 11 months ago #

    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

  5. Chip Bennett
    Member
    Posted 11 months ago #

    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.

Reply

You must log in to post.

About this Topic

Tags