• 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 insert custom markup outside of header's .wrap?

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 › How to insert custom markup outside of header's .wrap?

This topic is: resolved

Tagged: custom-markup

  • This topic has 9 replies, 3 voices, and was last updated 12 years, 2 months ago by nunotmp.
Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • September 16, 2013 at 5:40 am #62800
    pathetix
    Member

    Default Genesis template has a header with a .wrap div.
    Would like to know how I can add custom markup with another .wrap div just before the header closes.

    Current:
    .site-header
    >>.wrap
    .nav-primary

    Custom:
    .site-header
    >>.wrap
    >>.customwrap
    .nav-primary

    September 16, 2013 at 7:27 am #62810
    nunotmp
    Member

    Genesis uses the following hooks to create the header markup

    
    add_action( 'genesis_header', 'genesis_header_markup_open', 5 );
    add_action( 'genesis_header', 'genesis_header_markup_close', 15 );
    

    with add_action( 'genesis_header', 'genesis_header_markup_close', 15 ); closing the </header> (html5) or the </div>(xhtml). You can follow the same pattern and create you actions like so

    
    add_action( 'genesis_header', custom_wrap_open', 12 );
    add_action( 'genesis_header', 'custom_wrap_close', 14 );
    

    This will hold the openig a closing markup and you can simply add your actions using the priority of 13 like so

    
    add_action( 'genesis_header', 'everything_within_custom_wrap', 13 );
    

    Or an even easier if you do not really need to add so many thing just create a single action

    
    add_action( 'genesis_header', 'wpz_custom_wrap', 13 );
    function wpz_custom_wrap() {
    echo '<div class="custom-wrap">';
          // add anythiing you want within the wrap
    echo '</div">';
    }
    

    Genesis Child Themes – Follow Me

    September 16, 2013 at 11:22 am #62844
    pathetix
    Member

    Thanks @nunotmp for the reply, I think I understand your solution.
    However I can't get the markup to be outside of the header .wrap div.

    I Implemented your solution:`add_action( 'genesis_header', 'custom_wrap_open', 12 );
    add_action( 'genesis_header', 'custom_wrap_close', 14 );
    add_action( 'genesis_header', 'everything_within_custom_wrap', 13 );

    function custom_wrap_open() {
    echo '<div class="custom-wrap">';
    }
    function custom_wrap_close() {
    echo '</div">';
    }
    function everything_within_custom_wrap() {
    echo '<h1>HELOOOO</h1>';
    }`

    That generated:`<header>
    <div class="wrap">
    <div class="title-area">...</div>
    <div class="custom-wrap"><h1>HELOOOO</h1></div>
    </div>
    </header>`

    What I would like to achieve is the custom markup to be the sibling of the header .wrap div.
    I really appreciate your explanation though.

    September 16, 2013 at 11:51 am #62846
    nunotmp
    Member

    Sorry about that. I just re-read you question. This will require quite a bit of work. Genesis since 2.0 automatically adds the .wrap in the header. What exactly are you wanting to do? Maybe there is an easier way?


    Genesis Child Themes – Follow Me

    September 16, 2013 at 12:01 pm #62851
    nunotmp
    Member

    You know what, do this.

    
     remove_action( 'genesis_header', 'genesis_header_markup_close', 15 );
    add_action( 'genesis_header', 'wpz_header_markup_close', 15 );
    
    function wpz_header_markup_close() {
    
    	genesis_structural_wrap( 'header', 'close' );
    
    	do_action( 'wpz_after_header_wrap' );
    
    	genesis_markup( array(
    		'html5' => '</header>',
    		'xhtml' => '</div>',
    	) );
    
    }
    

    What this does is removed the genesis closeing markup and inserts our custom markup. I added a custom hook after the .wrap and before the </header> so you can then use the example above to add the custom markup like so

    
    add_action( 'wpz_after_header_wrap', custom_wrap_open', 12 );
    add_action( 'wpz_after_header_wrap', 'custom_wrap_close', 14 );
    
    add_action( 'wpz_after_header_wrap', 'everything_within_custom_wrap', 13 );
    

    The WPZ is my personal prefix you can change it.


    Genesis Child Themes – Follow Me

    September 17, 2013 at 7:22 am #62971
    pathetix
    Member

    Sorry for the late reply but I was trying to understand what you did.

    It works! It's kind of a long solution but it works.
    I was already contemplating on just building a custom theme but now I don't have to;

    Thanks for the explanation, I really appreciate this.

    September 17, 2013 at 7:31 am #62973
    pathetix
    Member

    Btw how did you came up with genesis_header_markup_close ?
    I don't see it in the hooks reference page.

    September 17, 2013 at 9:27 am #62984
    nunotmp
    Member

    If you look at the Genesis files you can navigate to Genesis>lib>structure>header.php. This is where these functions are created.

    add_action( 'genesis_header', 'genesis_header_markup_open', 5 );
    add_action( 'genesis_header', 'genesis_header_markup_close', 15 );
    

    You don't really have to create a custom hook, you can insert your markup directly into the header_close function but I like to use hooks. 🙂


    Genesis Child Themes – Follow Me

    September 17, 2013 at 7:36 pm #63094
    Gary Jones
    Member

    Just wanted to add - @nunotmp - good work - this is exactly the method I used to move primary and secondary nav into the header, but outside of the header wrap.


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

    September 23, 2013 at 10:47 pm #63931
    nunotmp
    Member

    @garyj Thank you. Its good to know I got the thumbs up from a developer of your caliber. : -)


    Genesis Child Themes – Follow Me

  • Author
    Posts
Viewing 10 posts - 1 through 10 (of 10 total)
  • The forum ‘General Discussion’ 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

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