Blog Sidebar in Genesis

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 );
view raw functions.php hosted with ❤ by GitHub

Bill Erickson

Bill Erickson is a freelance WordPress developer and a contributing developer to the Genesis framework. For the past 14 years he has worked with attorneys, publishers, corporations, and non-profits, building custom websites tailored to their needs and goals.

Ready to upgrade your website?

I build custom WordPress websites that look great and are easy to manage.

Let's Talk