Force a layout for Pages that have subpages in Genesis

Posted on
5/5 - (293 votes)

Adding the following in child theme’s functions.phps will apply content-sidebar layout to all static Pages that have children and overrides the default layout set in Genesis theme settings (but not the one applied at Page level):

// Apply layout to static Pages that have children (subpages)
add_action( 'get_header', 'sk_force_layout' );
function sk_force_layout() {

	global $post;

	// if we are on a static Page and if it does not have a parent
	if ( is_singular( 'page' ) && !$post->post_parent ) {
		add_filter( 'genesis_pre_get_option_site_layout', '__genesis_return_content_sidebar' );
	}

}