• 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

Correct Include Funtion

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 › General Discussion › Correct Include Funtion

This topic is: resolved

Tagged: include funtions in Genesis

  • This topic has 4 replies, 2 voices, and was last updated 4 years, 9 months ago by Gary Jones.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • April 28, 2018 at 6:13 pm #219365
    Angelo
    Member

    Hello, I have created a function and I would like to know if I am doing it correctly.

    1) I have removed the default header from genesis.
    2) I have created a file called header.php
    3) I put the html code in the file
    4) I included the file in the header with the following function

    function CustomHeader() {
       include("cabecera.php"); 
    };
    add_action('genesis_header', 'CustomHeader');

    Everything works fine, however, I would like to know if it really is the right way.

    https://www.facebook.com/angeloaguilarq
    April 28, 2018 at 6:37 pm #219368
    Gary Jones
    Member

    I hope by 1. you mean you've unhooked genesis_do_header, rather than directly edited Genesis files...

    In terms of the code snippet, I'd flesh it out as:

    remove_action( 'genesis_header', 'genesis_do_header' );
    add_action( 'genesis_header', 'angelo_do_header' );
    /**
     * Include custom header contents.
     *
     * @since 1.0.0
     */
    function angelo_do_header() {
       include __DIR__ . '/cabecera.php'; 
    }

    There are several differences going on here, including code standards, documentation, best practices and cleaner code.


    WordPress Engineer, and key contributor the Genesis Framework | @GaryJ

    April 29, 2018 at 4:16 pm #219417
    Angelo
    Member

    Yes Gary, I did it Like This:

    // Remove site header elements.
    remove_action( 'genesis_header', 'genesis_header_markup_open', 5 );
    remove_action( 'genesis_header', 'genesis_do_header' );
    remove_action( 'genesis_header', 'genesis_header_markup_close', 15 );
    
    function CustomHeader() {
       include("cabecera.php"); 
    };
    add_action('genesis_header', 'CustomHeader');

    I must confess that I'm just an amateur, I'm not a programmer. That's why I ask, because I'd like to do it the right way.
    Thank you very much, I will do as you indicate

    April 29, 2018 at 5:31 pm #219426
    Angelo
    Member

    Hey Gary, according to what you have indicated, if I wanted to do the same with the footer ...it would be like this?

    remove_action( 'genesis_footer', 'genesis_do_footer' );
    add_action( 'genesis_footer', 'angelo_do_footer' );
    function angelo_do_footer() {
       include __DIR__ . '/myfooter.php'; 
    }

    Is this correct ?
    I just did it, it Woks Fine

    April 30, 2018 at 12:46 am #219434
    Gary Jones
    Member

    If it works, it's correct 🙂


    WordPress Engineer, and key contributor the Genesis Framework | @GaryJ

  • Author
    Posts
Viewing 5 posts - 1 through 5 (of 5 total)
  • The topic ‘Correct Include Funtion’ 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

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