• 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

How to make Genesis load custom HTML/PHP file in a specific hook position

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 › How to make Genesis load custom HTML/PHP file in a specific hook position

This topic is: not resolved
  • This topic has 3 replies, 2 voices, and was last updated 5 years, 6 months ago by Victor Font.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • January 25, 2017 at 9:52 am #200007
    Konspaul
    Member

    This must be the simplest thing to do – for someone who knows PHP. I don't. So I've been looking for past 3 hours an answer. Didn't find :(. Please help me.
    I have a smile.php file that has this code:

    
    <div class="be-happy">
      <h1>Great things</h1>
      <p>A rabbit jumped over a fox and got eaten.</p>
    </div>
    

    What do I have to write in my function.php file to make this 4 lined code injected in Genesis genesis_after_header hook?

    January 25, 2017 at 10:28 am #200011
    Konspaul
    Member

    I now know that I could do this in my function file:

    
    function content_after_header() {
      echo ( '<div class="be-happy">
                    <h1>Great things</h1>
                    <p>A rabbit jumped over a fox and got eaten.</p>
                 </div>' );
    }
    add_action('genesis_after_header', 'content_after_header');
    

    But my goal is to have a separated into theme injectable .php file so I will be able to edit it and change the content without opening the function file. I'm still looking for a way to load a custom php file.

    January 25, 2017 at 10:37 am #200012
    Konspaul
    Member

    Maybe writing

    
    include('child-theme/smile.php');
    

    in my function.php and having that function mentioned above in my smile.php would work but I'm sure there must be more sophisticated method.

    January 25, 2017 at 2:09 pm #200026
    Victor Font
    Moderator

    No. There's not a more sophisticated method. That's the right way to do it. BTW, echo doesn't use parens.


    Regards,

    Victor
    https://victorfont.com/
    Call us toll free: 844-VIC-FONT (842-3668)
    Have you requested your free website audit yet?

  • Author
    Posts
Viewing 4 posts - 1 through 4 (of 4 total)
  • The forum ‘Design Tips and Tricks’ is closed to new topics and replies.

CTA

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

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2022 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