WP Smith

Creating WordPress & Genesis Websites Since 2010

  • Home
  • About
  • Services
  • Blog
  • Contact

Mar 17 2011

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

  • Content/Sidebar = ‘content-sidebar’
  • Sidebar/Content = ‘sidebar-content’
  • Content/Sidebar/Sidebar = ‘content-sidebar-sidebar’
  • Sidebar/Sidebar/Content = ‘sidebar-sidebar-content’
  • Sidebar/Content/Sidebar = ‘sidebar-content-sidebar’
  • Full Width Content = ‘full-width-content’

Written by Travis Smith · Categorized: Genesis, Tutorials

StudioPress Premium WordPress Themes     WP Engine Managed WordPress Hosting

What can I do for you!?

Custom Development

We develop plugins by determining both business/functional and technical requirements, following WordPress development best practices, and using agile methodology to ensure you get the best solution.

Consulting

Have questions? Need a reliable developer to consult? Please contact us today!

Customized Theme

We can customize your theme or child theme, or create a child theme for you based on your needs while enhancing the performance of every individual attribute.

Customized Plugin

We can customize your plugins, extend plugins (e.g., Gravity Forms, Jetpack, Soliloquy) based on your needs ensuring security, performance, and positive business impact.

Contact Us

About Travis Smith

As a WordPress enthusiast, developer, and speaker, Travis writes about what he learns in WordPress trying to help other WordPress travelers, beginners and enthusiasts with tutorials, explanations, & demonstrations.

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

  • Twitter
  • Facebook
  • LinkedIn
  • Google+
  • RSS

Copyright © 2025 � WP Smith on Genesis on Genesis Framework � WordPress � Log in