I have recently (yesterday) taken the plunge into building my websites with Genesis. I’m not exactly sure why I’ve been holding out. Most likely because I had built my own kind of framework and really like some specific things I had built into it. The problem is that I just don’t have time to work on all the other stuff that’s important for a good theme framework. So now I’m using Genesis and I couldn’t be happier. I still needed to solve a problem though so here it is.
I wanted my default layout to be CONTENT-SIDEBAR but I wanted a particular post types archives and single posts to be SIDEBAR-CONTENT. With the Genesis genesis-cpt-archives-settings custom post type support I can accomplish this for the archive pages but not for the single posts. This snippet solves that problem.
function wpnj_cpt_layout() { if( 'your_post_type' == get_post_type() ) { return 'sidebar-content'; } } add_filter( 'genesis_site_layout', 'wpnj_cpt_layout' );
This code checks what custom post type you are viewing and applies this layout if it’s the one you’re looking for. Pretty simple.
Tom says
One of the great things I’ve found about Genesis are the number of quality plug-ins that are available to do things without having to code for results. There’s certainly nothing wrong with adding code, but the plug-ins are an instant go-to solution and most offer easy what-if sampling and other options. You can also use them from site to site where you may be using different Genesis themes.
For instance, you should be able to get the same results for your CPT using David Decker’s “Genesis Layout Extras” plugin, which offers a layout selection per CPT and adds layout options not offered by Genesis. Even though Genesis has up to 6 layouts, David’s plugin adds at least 3 additional layouts and adds 9 additional layouts if your theme supports alt-sidebars (secondary sidebars).
Jim Proctor says
I’ve used Genesis Layout Extras as well, but it hasn’t been updated recently and is incompatible with at least one of my other plugins (running WP 4.4.1). I would love to modify your code for it to check not for a certain post type, but to check whether the page is the home page, and if so to apply a certain layout…is this possible? I don’t want to redo the whole front-page.php format for my child theme; I just want a different layout for the home page, and Genesis Layout Extras did this for me fine…until it started messing with other plugins.
Sure appreciate!
Jim P.
Manning Stinson says
You may want to also check out u-Design. Awesome framework. I am using Ninja Forms with the theme and have had know theme conflicts at all.
http://themeforest.net/item/udesign-wordpress-theme/253220
Manning Stinson says
*** NO known!
Chris Ward says
Thanks for this James, it solved exactly what I was looking for.
Jim Proctor says
Ah, that was easy…thanks for the inspiration…
if ( is_home() ) {
return ‘sidebar-content-sidebar’;
}