Last active
August 7, 2018 17:58
-
-
Save geeac/92a6bd339b1c5a5f9476a1bb280a691a to your computer and use it in GitHub Desktop.
Genesis force layout conditionally on certain pages
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//* Add sidebar to blog posts | |
add_action( 'genesis_pre_get_option_site_layout', 'gc_add_primary_sidebar' ); | |
function gc_add_primary_sidebar() { | |
if ( is_home() || is_singular('post') || is_category() || is_month() ) { // for archives and single post pages | |
/* list of options | |
content-sidebar | |
sidebar-content | |
content-sidebar-sidebar | |
sidebar-sidebar-content | |
sidebar-content-sidebar | |
full-width-content */ | |
$opt = 'content-sidebar'; | |
return $opt; | |
} | |
} | |
// Full Width Pages on WooCommerce | |
function gc_fullwidth_layout() { | |
if( is_page ( array( 'cart', 'checkout' )) || is_shop() || 'product' == get_post_type() ) { | |
return 'full-width-content'; | |
} | |
} | |
add_filter( 'genesis_site_layout', 'gc_fullwidth_layout' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment