This snippet will let you register a Blog Sidebar, and use that sidebar through the blog section of your site (blog home, single posts, categories, tags…). The Primary Sidebar will be used for the rest of the website.
<?php | |
/** | |
* Add a Blog Sidebar to Genesis | |
* | |
* @author Bill Erickson | |
* @link http://www.billerickson.net/code/blog-sidebar-genesis/ | |
*/ | |
/** | |
* Register Blog Sidebar | |
* | |
* @author Bill Erickson | |
*/ | |
function be_register_blog_sidebar() { | |
genesis_register_sidebar( array( 'id' => 'blog-sidebar', 'name' => 'Blog Sidebar' ) ); | |
} | |
add_action( 'genesis_setup', 'be_register_blog_sidebar', 20 ); | |
/** | |
* Display Blog Sidebar | |
* | |
* @author Bill Erickson | |
*/ | |
function be_blog_sidebar() { | |
if( !( is_home() || is_category() || is_tag() || is_singular( 'post' ) ) ) | |
return; | |
remove_action( 'genesis_sidebar', 'genesis_do_sidebar' ); | |
if( function_exists( 'ss_do_sidebar' ) ) | |
remove_action( 'genesis_sidebar', 'ss_do_sidebar' ); | |
dynamic_sidebar( 'blog-sidebar' ); | |
} | |
add_action( 'genesis_sidebar', 'be_blog_sidebar', 5 ); |