Free Tips & Tricks!

Join the others who've found my articles helpful! Get free goodness delivered to your inbox each time I share something new.

p.s. I'd gnaw my arm off before selling your email address.

Customize Genesis: Move Header Above the Wrap with Structural Action Hooks

Earlier this year I wrote a post on how to move the header and footer outside the structural wrap in a Genesis child theme. The instructions I laid out in that post didn’t apply to every single StudioPress child theme (not all themes fit the same structural mold). I’ve had multiple questions related specifically to moving the header in the Prose Child Theme, so here are the specifics on how to do that!

Note: I have not tested these instructions on other Genesis Child Themes, but the principles should still apply.

Default Structure of Prose

I like to use the Firebug browser plugin (available on Firefox, Chrome, or Safari) to see what’s going on with the HTML and CSS behind the scenes on a web page. Using it on the Prose theme, I can see that the default structure is this:

Prose Child Theme HTML Structure

There’s the main wrap (id=”wrap”) and then we get the nav, header, inner, and footer widgets. Note that the footer div is already outside the main wrap. We don’t have to do anything to move it, but you can add some CSS to make it stretch the full width of the screen.

When we’re done with this tutorial, the header will be bumped up over the main wrap, like this:

Prose Child Theme Modified Structural Wraps

Move Your Genesis Header Above the Main Wrap

We’re about to bust out with some Genesis structural action hooks. You ready?

For those of you that just want the code, here it is:

/** Reposition header outside main wrap */
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 ) ;

add_action( 'genesis_before', 'genesis_header_markup_open', 5 );
add_action( 'genesis_before', 'genesis_do_header' );
add_action( 'genesis_before', 'genesis_header_markup_close', 15 );

If you’re using Prose, plop that in your Genesis > Custom Code > Custom Functions box. If you’re referring to this tutorial for a different Genesis child theme that doesn’t have a Custom Code menu option, then add this to your functions.php (or wherever you add custom code to your theme).

Let’s talk about WHY this code works.

The first three remove_action() hooks will unhook the header (and header markup divs) and get rid of the default Prose layout.

/** Ditch the Genesis header structural markup and the header code*/
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 ) ;

The last three remove_action() hooks will re-hook the header into your theme right after the opening tag (which also happens to be outside the main wrap).

/** Add in Genesis header structural markup and header code */
add_action( 'genesis_before', 'genesis_header_markup_open', 5 );
add_action( 'genesis_before', 'genesis_do_header' );
add_action( 'genesis_before', 'genesis_header_markup_close', 15 );

Okay, makes sense. But what’s up with those numbers at the end?? Read on.

Get your priorities straight

Those numbers we’re passing to our action hooks tell WordPress the order (or priority) to fire off our code. The default priority is 10 – lower numbers are executed earlier and higher numbers later.

The action hooks above are listed in order: 5, 10 (it’s a “silent 10″), and 15. This makes sure the code executes in the right order, first with genesis_header_markup_open, then sandwiching in our genesis_do_header code, and finally, wrapping it up with genesis_header_markup_close.

Bonus Code for Footer

Since the Prose theme places the footer outside of the main wrap, we don’t need to move it. BUT, if you’re reading this post and working with a theme that has the footer inside the main wrap and would like to move it below, you can try this:

/** Reposition footer outside main wrap */
remove_action( 'genesis_footer', 'genesis_footer_markup_open', 5 );
remove_action( 'genesis_footer', 'genesis_do_footer' );
remove_action( 'genesis_footer', 'genesis_footer_markup_close', 15 ) ;

add_action( 'genesis_after', 'genesis_footer_markup_open', 5 );
add_action( 'genesis_after', 'genesis_do_footer' );
add_action( 'genesis_after', 'genesis_footer_markup_close', 15 );

These structural action hooks follow the same pattern as the code we used for the header. First we unhook the footer (and its markup) from the default location and then we hook it back in where we want it. If the concept of hooks and their location is new to you, I highly recommend taking a look at this visual hook guide. You can even install the Genesis Visual Hook Guide plugin to see hooks in action in your own theme.

That’s all, folks!

If you’d like to see CSS samples to customize Genesis with a full-width header or footer, just leave a comment below.

Comments

  1. Great Article, and great tip on priorities. I think it’s one of those things that’s constantly over looked.

    I usually use css to get the same effects, and add the structural class wraps. I like your way though, probably less coding and less thinking involved =)

    Great article!

    • Carrie Dils says:

      I like the CSS route, too. Sometimes a theme needs both, depending on whether the width is set as part of the body or the #wrap. Thanks, Jonathan!

  2. Thanks, you save my time since I’m new with Genesis Framework.

    Bookmarked this :D

  3. Thank you for this! I and brand new to wordpress/Genesis and have NO coding knowledge whatsoever (which is why I went with Prose!) . I managed to follow your tutorial just fine – however now I am wondering what I do to get the header and footer to be full width now that it is outside the wrap area? Does this need to be accomplished in the Coding Editor section? Thanks :)

    • Hey Angela,
      Yep, you can add your custom CSS to Genesis > Custom Code. With Prose, the site width is specified in the body tag, so you’ll need to make your body 100% and then go back and and make the inner elements a fixed width.

      Try this:


      body {
      width: 100%;
      }
      #header .wrap,
      #footer .wrap,
      #footer-widgets .wrap {
      margin: 0 auto;
      max-width: 970px; //This is the default Prose width, but you can change it if you want.
      }

      If you wanted to change the background color for your header & footer, you could do something like this:


      #header, #footer {
      background-color: #666;
      }

      See if that helps. Feel free to come back and post a link to show off your progress. :)

      Cheers,
      Carrie

      • Hi Carrie,

        How do I make the header image full-width and keep the menu aligned with the content? The code above made my menu longer (I might end up keeping that way) but keeps my header image aligned with my content.

        Thanks. I appreciate your help.

        • Hi Jonsky,
          Typically you’ll make your outer wrap (maybe .header or #header in your CSS) 100% and then have your inner menu wrap (maybe .wrap) be set to a fixed width and the margin set to “0 auto” to center.

          If that doesn’t work, post the URL in question and I’ll take a look.

          Cheers,
          Carrie

          • Hi there, Carrie. GREAT tutorial, thank you!

            What might that look like in css, exactly? The link to my in-progress site is http://sukha.creatrixdesign.net/devsite/ . As you can see, both of my menus are drifting off the left of the page. Thanks so much!

            Aimee

          • Hi there,
            Try confining your #nav .wrap to a width of 960px and setting your margin to center. So it would look like this:

            #nav .wrap {
            margin: 0 auto;
            width: 960px;
            }

            Same principle will apply to your second menu.
            Carrie

  4. Yay!

    It worked! Thanks so much! IThat made it so much more clear – I thought I had to go to Appearance – Editor to make changes and it was overwhelming to figure out what was what – but just cutting and pasting into the Custom section is a piece of cake! That makes sense to me.

    My site is so new – I havent even made a post yet, but I am trying to get a basic design down first! The site is http://hereiamnowwhat.com/

    Thanks again so much!

    :)

  5. I just discovered your blog and it is a lifesaver!

    Can you offer a suggestion on here or via email?

    I’m using Prose, and have added all the above code as written. However, my site looks wonky. (Official, technical term.) Here’s the site: http://www.tobystevens.net

    The order appears as such:

    Header Image – within body frame?
    Nav Menu – full-width
    Blog content – within body
    Footer Widgets – full-width
    Footer – within body frame?

    What am I missing?

    • Hi Ellen,
      You just need a few CSS tweaks. You’ve got your #header at max-width: 940px. Remove that so that it can be full width and then specify your max-width for your #header .wrap.

      Remove this line from your #footer-widgets .wrap – border: 1px solid #FFFFFF; and that’ll get rid of the odd border.

      Do you use Firebug for Firefox or Chrome? It makes trouble-shooting CSS 100x easier. :)

      Carrie

      • I’ve tried all of these (header width and footer border) and something is still not working. Any other ideas?

        Also, what is Firebug?

        Thanks for your patience.

        • If you can avoid being grossed out by the bug icon, check out: https://getfirebug.com/. You can install it as browser add-on for Firefox or Chrome. Then, you can right-click any element on your browser page and select “inspect element” – it shows you the CSS behind a specific element on the screen. Even lets you live edit the CSS to figure out what changes you need to make to your stylesheet.

          It’s awesome.

      • Also, I notice that when I resize the screen, the body is completely covered by the background color and content diappears. What happens with this?

  6. Thanks Carrie, helped a lot!

  7. Hi,

    How would I reposition a custom widget area outside the wrap? I’m on the metro theme and the footer is already outside the wrap. I see in the functions it was done with exact code you listed here. I’ve created the widget to hook before the footer but it shows up in the wrap.

    Thank you,

    Doug

  8. I just figured it out. I had this: add_action( ‘genesis_before_footer’, ‘metro_home_contact’ ) and I changed it to this: add_action( ‘genesis_after’, ‘metro_home_contact’, 2 ). I pieced it together on a whim after reading your post. Thank you.

  9. Hello and thank you for your post!

    Unfortunately, this didn’t work for me and I a little puzzle by what is happening.
    I am creating a brand new child theme, from the latest GENESIS 1.9.1 and I simply wanted to move header and footer out of the wrap.
    I’ve created a new functions.php file in my own theme directory and added your lines of code to reposition header and footer.
    It did add a header and footer out the wrap but it didn’t remove the original header and footer.
    So now I have 2 headers and 2 footers, one inside the wrap and one outside.

    For a test, I installed the prose theme, and it works as supposed, with the footer out of wrap. I checked its functions.php file and it matches the the lines for the footer on your post.
    So I was wondering if you could help me understand why the same lines of code would work on the Prose theme but not on my own brand new theme…

    Thank you for you help

  10. Bud Fawcett says:

    Carrie, thanks for your info. I have moved the header above the wrap but I would also like to center the header to the browser window and have it follow the wrap rather than having it flush left to the browser. Any advice.
    thanks
    Bud

    • Hey Bud,
      You’ll want to make sure there’s a width set on the parent element containing the logo (probably ‘header’). Once that’s done, make sure that float isn’t specified (float: none) and that your margin is set for centering (margin: 0 auto).
      Carrie

  11. Bud Fawcett says:

    I guess the natural question to follow is how to move the menu nav as well above the wrap (full width menu with the menu items aligning with wrap) so that it stays with the header and looks normal. Thanks

  12. This worked great with the footer! But what about the footer widget areas?

    • Never mind! I found the answer using this … :)

      // Relocate footer widgets
      remove_action( ‘genesis_before_footer’, ‘genesis_footer_widget_areas’ );
      add_action( ‘genesis_after’, ‘genesis_footer_widget_areas’, 1 );

  13. Thanks for the code snippet…came in handy today! Used it at

  14. Hey, I stumbled on to your site searching for ways to make container width wider in Genesis Prose Theme. Would you know how to do that? I can’t seem to find this information anywhere on google and have made few CSS code attempts without any success. Thanks.

    • Hi Peter,
      In a Genesis theme, the parent width is typically set by the main body tag or the wrap tag. You can use Firebug to figure out which it is and then change your CSS accordingly. Here’s a Firebug demo if you’re not familiar with it. :)

      Carrie

  15. You just saved me HOURS of searching! Thank you so much, this is exactly what I was looking for!

  16. Please how do i remove the prose footer credit entirely and use customized one which appeared inside rap

  17. Thanks for the tutorial. I’m trying to move the header and the nav outside the wrap. It works but the nav gets put inside the header wrap. How do you move the nav under the header with it’s own structural wrap?

Trackbacks

  1. [...] Drop this code like a hot potato into Genesis > Extender Custom > Functions and watch the magic unfold. If you want to know why this code works, read this post. [...]

  2. [...] De oplossing vond ik op: www.carriedils.com. [...]

  3. [...] Customize Genesis: Move Header Above the Wrap with Structural Action Hooks [...]