Force a layout in a template

Here’s a code snippet you can use when you want to lock down a layout for a specific template. Just drop the following into a single-posttype.php, template-something.php, etc before the genesis() function:

/** Force full width layout */
add_filter( 'genesis_pre_get_option_site_layout', 'child_do_layout' );
function child_do_layout( $opt ) {
    $opt = 'full-width-content'; // You can change this to any Genesis layout below
    return $opt;
}

As a reminder, Genesis comes with 6 default layouts:

content-sidebar
sidebar-content
content-sidebar-sidebar
sidebar-sidebar-content
sidebar-content-sidebar
full-width-content

See Brian Gardner’s post on creating a landing page in Genesis for a practical example of how you would use this.

Comments

  1. How about using it in a custom function like this https://gist.github.com/braddalton/5547550

    • Hi Brad, thanks for sharing that! We should point out that your code goes into functions.php and affects the site globally. I should have been clearer that I wanted to target a specific template. For example, you could put the code in a Page Template for a sales page

Speak Your Mind

*

Follow

Get every new post delivered to your Inbox

Join other followers: