Skip to content

Instantly share code, notes, and snippets.

@jeremyjaymes
Last active July 9, 2024 22:03
Show Gist options
  • Save jeremyjaymes/3de69a2ebbd82c924ca3 to your computer and use it in GitHub Desktop.
Save jeremyjaymes/3de69a2ebbd82c924ca3 to your computer and use it in GitHub Desktop.
Add Genesis Sidebar area to Custom Post Template
<?php
/**
* Opening PHP tag is likely not needed
* Functions are added to our custom single post template
*/
//* Hook our sidebar logic to get_header
add_action( 'get_header', 'mytheme_sidebar_function' );
//* Remove the primary sidebar, swap in our custom sidebar
function mytheme_sidebar_function() {
//* removes primary
remove_action( 'genesis_sidebar', 'genesis_do_sidebar' );
//* adds custom sidebar
add_action( 'genesis_sidebar', 'mytheme_do_custom_sidebar' );
}
//* Retrieve our custom sidebar
function mytheme_do_custom_sidebar() {
genesis_widget_area( 'custom-post-sidebar', array(
'before' => '<div class="widget-area">',
'after' => '</div>',
) );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment