Skip to content

Instantly share code, notes, and snippets.

@j-mccarthy
Last active August 29, 2015 14:09
Show Gist options
  • Save j-mccarthy/a716e6d80ea170e5bb3a to your computer and use it in GitHub Desktop.
Save j-mccarthy/a716e6d80ea170e5bb3a to your computer and use it in GitHub Desktop.
<?php // <- Remove <?php if your using this snippet
// Register New Layout
function jm_custom_layout() {
genesis_register_layout( 'layout-name', array(
'label' => __('custom/layout/name', 'genesis'),
'img' => get_bloginfo('stylesheet_directory') . '/images/yourlayout.gif'
) );
}
add_action( 'init', 'jm_custom_layout' );
/* Register sidebar and in with this way of outputting the sidebar, make sure you create
* A new sidebar-template.php file holding your custom hooks see here for an example
* https://gist.github.com/StudioMomentum/623564f499ba3c65d50b#file-genesis_sidebar_template-php
*/
genesis_register_sidebar(array(
'name'=>'NewSidebar',
'id' => 'sidebar-new',
'description' => 'Short description of your new sidebar'
));
// New layout Logic
function jm_custom_layout_logic() {
$site_layout = genesis_site_layout();
if ( $site_layout == 'layout-name' ) {
// Remove default genesis sidebars so now we jsut have the main content being loaded
remove_action( 'genesis_after_content', 'genesis_get_sidebar' );
remove_action( 'genesis_after_content_sidebar_wrap', 'genesis_get_sidebar_alt');
// Add layout our new sidebar
add_action( 'genesis_after_content_sidebar_wrap', 'jm_get_sidebar' );
}
}
add_action('genesis_before', 'jm_custom_layout_logic');
// hooks into sidebar-yourNewName.php to add the widget area
add_action( 'jm_sidebar', 'jm_do_sidebar_bottom' );
function jm_do_sidebar_bottom() {
if ( !dynamic_sidebar( 'sidebar-new' ) )
genesis_widget_area( 'sidebar-new' )
;
}
// Lets get our beautiful hooked up sidebars. These functions are added
// into the child theme back up in the layout logic.
function jm_get_sidebar() {
get_sidebar( 'new' );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment