Site icon WP Smith

How to Force a Specific Layout to Prevent User Error

Ever worry that your client will change or break your custom pages you built for them (e.g., homepage, 404 page, etc.)? Or, do you worry that in their snooping they will change the default page layout to something other than the default on archive pages (ex: category). The example below is to set the category and archive pages to Sidebar-Content-Sidebar and home page to Sidebar-Content.

[php]
// Force layout on category
add_filter('genesis_pre_get_option_site_layout', 'be_category_layout');
function be_category_layout($opt) {
if ( is_category() || is_archive() )
$opt = 'sidebar-content-sidebar';
return $opt;
}
// Force layout on home
add_filter('genesis_pre_get_option_site_layout', 'be_home_layout');
function be_home_layout($opt) {
if ( is_home() ) //May also be is_front_page()
$opt = 'sidebar-content';
return $opt;
}
[/php]

The available layout options are