Site icon WP Smith

How to Add Genesis Child Theme CSS Wraps (Structural Wraps) Easily and Quickly

So, since Genesis 1.6, and probably my favorite part of Genesis 1.6 is the theme support of genesis-structural-wraps. So now you can easily add wraps to the header, nav, subnav, inner, footer-widgets, and footer. This is something I found myself doing A LOT! And I guess I wasn't the only one!

Previously to add an #inner wrap, for example, you had to:
[php]// Add div.wrap inside of div#inner
function child_before_content_sidebar_wrap() {
echo '<div class="wrap">';
}
add_action('genesis_before_content_sidebar_wrap', 'child_before_content_sidebar_wrap');

function child_after_content_sidebar_wrap() {
echo '</div><!-- end .wrap -->';
}
add_action('genesis_after_content_sidebar_wrap', 'child_after_content_sidebar_wrap');
[/php]

And this didn't work all the time. For example, customizing the Agency theme, it wasn't this simple. One still had to modify home.php and move a hook to make the wrap work appropriately (and I am sure that the Agency theme wasn't the only one!).

Now, it is one line of code:
[php]add_theme_support( 'genesis-structural-wraps', array( 'header', 'nav', 'subnav', 'inner', 'footer-widgets', 'footer' ) );[/php]

While this one line doesn't solve the Agency theme problem of adding a wrap, it does make adding wraps easier and simpler without any unnecessary extra code or failing to close a <div> tag at the wrong spot!