WordPress.org

Ready to get started?Download WordPress

Forums

Which php code? Text area above posts only on homepage (3 posts)

  1. Lisa {Sweet 2 Eat Baking}
    Member
    Posted 2 years ago #

    Hi all,

    I'm looking for some quick help. I'm looking to place a block of text in the exact same place as shown in the navigation area which states "You are here: Home / Cookies / Monster Cookies" but displays only on the home page and not on any archives, posts or pages. See this page to see what I mean: http://www.sweet2eatbaking.com/monster-cookies/

    I'm a complete newbie to php coding and am using a plugin by Genesis (Simple Hooks) to achieve this. I've found the right area in which to place my HTML code but I don't know how to make it show only on the home page. I found this WordPress information (http://codex.wordpress.org/Conditional_Tags) but when applying it, I think I'm doing something wrong.

    I just want some HTML code to welcome any users that land on my homepage with some social networking things. Something along the lines of...

    <?php is_home(); ?>
    <div class="breadcrumb">
    <p>Welcome to Sweet 2 Eat Baking. If you are new here, you might like to subscribe to our RSS Feed or get sugar filled e-mails! You'll be the first to get updates! You can also find me over at Twitter, Facebook, and Pinterest. You can also read more about me here. Happy baking!</p>
    </div>

    If I enter the above in, it displays just fine but shows on every page. What am I doing wrong? I'm assuming its either because..
    1). I've not closed the php tag? I don't know any php therefore I don't know what I'm doing at all with that.
    2). I'm using the wrong code from the conditional tags page. Which tag or code would I use to ensure that my HTML only displays on just the homepage of my site?

    Thanks in advance,
    -Lisa.

  2. bcworkz
    Member
    Posted 2 years ago #

    You're close, you just misunderstood how to properly use is_home(). Probably because the Usage section of is_home() in the Codex is misleading. Change the first line to: <?php if( is_home() ): ?> and then add this line after all your conditional html: <?php endif; ?>. Note the different use of colon vs. semi-colon.

  3. Lisa {Sweet 2 Eat Baking}
    Member
    Posted 2 years ago #

    Wonderful, thank you so much. It's working perfecto now.

    Thanks for your help and time. I appreciate it.

Topic Closed

This topic has been closed to new replies.

About this Topic