The snippet below will force the homepage layout of your child theme.
New Way
add_filter('genesis_pre_get_option_site_layout', 'custom_home_layout'); function custom_home_layout($opt) { if ( is_home() ) $opt = 'full-width-content'; return $opt; }
Old Way
add_filter('genesis_options', 'custom_home_layout', 10, 2); function custom_home_layout($options, $setting) { if($setting == GENESIS_SETTINGS_FIELD) { if(is_home()) $options['site_layout'] = 'full-width-content'; } return $options; }
* Note This code can be used to force the layout for pages, categories, archives and page templates. Just change
is_home()
to the conditonal you want. For use in a custom page template files just include it beforegenesis():
Layout Options:
content-sidebar
Content/Sidebar
content-sidebar-sidebar
Content/Sidebar/Sidebar
sidebar-sidebar-content
Sidebar/Sidebar/Content
sidebar-content-sidebar
Sidebar/Content/Sidebar
full-width-content
Full Width Content
Morgan Finley says
I adapted this to force a layout on a category page template by using the following:
Thanks, it works great. I’m a designer just getting into genesis and exploring custom child themes. I have been looking at code examples from here and from the StudioPress forums. Mostly, I have been looking for ways to manipulate the layouts, and this is very helpful.
Christopher says
Glad I could help! And thanks for the comment and snippet! I will be updating the site soon with many more snippets (I have quite a few) and the option for anyone to submit theirs.
Anyways, just to let you know I’ve updated the code above. There is a newer way to force the site (I have to check if the old way still works in the latest version of genesis).
Morgan Finley says
Thanks, I made the same changes to the new code and it works like a charm.
I look forward to more snippets and code tips.