• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

Add hook only on home page

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

Community Forums › Forums › Archived Forums › Design Tips and Tricks › Add hook only on home page

This topic is: resolved

Tagged: hooks

  • This topic has 5 replies, 4 voices, and was last updated 11 years, 11 months ago by nutsandbolts.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • April 29, 2014 at 2:06 pm #102984
    TGScreative
    Member

    I added an image underneath the navigation bar in the basic Genesis child theme.
    I used the hook "genesis_after_header"
    The image looks great but I only wanted it on the home page. Ay ideas how to use a hook only on one page on the site?

    I tried using a little PHP but not sure exactly how it works. This is the code I used.

    <?php if(is_home) { ?>
    <div style="background: #eeeeee; text-align: center;"><img src="/wp-content/uploads/2014/04/collage.jpg" width="1160" height="205"></div>
    <?php endif; ?>
    <?php } ?>
    http://nteu245.mystagingwebsite.com/
    April 29, 2014 at 5:38 pm #103010
    NewSeasonDesign
    Member

    I would do this:

    <?php if (is_home()) { ?><div style="background: #eeeeee; text-align: center;"><img src="/wp-content/uploads/2014/04/collage.jpg" width="1160" height="205"></div>
    <?php } ?>
    

    If is_home doesn't work, try is_front_page.

    Then make sure that you check the box for php under the hook. (Not that I've ever forgotten do that... ahem.)

    April 29, 2014 at 5:40 pm #103012
    nutsandbolts
    Member

    Try this:

    <?php if (is_home()) { ?><div style="background: #eeeeee; text-align: center;"><img src="/wp-content/uploads/2014/04/collage.jpg" width="1160" height="205"></div>
    <?php } ?>
    

    Edit: and I see Jen was ahead of me. 😀

    and be sure to check the box to execute PHP on the hook ( I'm assuming you're using Simple Hooks?).

    If your homepage isn't set to show posts in Settings > Reading and is set to a static page instead, you'll want to do this:

    <?php if (is_page(PAGE ID GOES HERE)) { ?><div style="background: #eeeeee; text-align: center;"><img src="/wp-content/uploads/2014/04/collage.jpg" width="1160" height="205"></div>
    <?php } ?>
    

    You can find the page ID by hovering over the Edit link for that particular page.


    Andrea Whitmer, Owner/Developer, Nuts and Bolts Media
    I provide development and training services for designers • Find me on Twitter and Google+

    April 30, 2014 at 1:41 pm #103102
    Brad Dalton
    Participant

    Here's another way to add an image after the header on the front page.

    Simply add your image to your child themes images folder and change the image file name in the code to match your image.

    Add Image After Front Page Primary Nav Menu Apparition Theme

    Also best practice to keep all your CSS in your child themes style sheet rather than use inline CSS


    Tutorials for StudioPress Themes.

    May 1, 2014 at 10:00 am #103188
    TGScreative
    Member

    Thank you. Works great NutsandBolts. Forgot about the static page being referenced by page ID

    May 1, 2014 at 10:04 am #103189
    nutsandbolts
    Member

    No problem! I’ve marked this topic as resolved for now, but feel free to open a new topic if you run into issues. 🙂


    Andrea Whitmer, Owner/Developer, Nuts and Bolts Media
    I provide development and training services for designers • Find me on Twitter and Google+

  • Author
    Posts
Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘Add hook only on home page’ is closed to new replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2026 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble