Community Forums › Forums › Archived Forums › General Discussion › Registering additional sidebar
Tagged: custom sidebar, Sidebar
- This topic has 5 replies, 2 voices, and was last updated 8 years, 4 months ago by
jmamuzich.
-
AuthorPosts
-
November 14, 2014 at 6:22 pm #131578
jmamuzich
MemberHello,
I am trying to register a third sidebar that will show only on specific pages. I have gotten it to show up in the back end but not on the front end. Here is my code:
// Register a new sidebar for Caravans
genesis_register_sidebar( array(
'id' => 'caravans-sidebar',
'name' => 'Caravans Sidebar',
'description' => 'This is the caravans sidebar widget area.'
) );add_action( 'get_header', 'trestle_sidebar_logic' );
function trestle_sidebar_logic() {
if ( is_page('3747') ) {
remove_action( 'genesis_after_content', 'genesis_get_sidebar' );
add_action( 'genesis_after_content', 'trestle_get_caravans_sidebar' );
}
}/**
* Retrieve our unique caravans page sidebar.
*/
function trestle_get_caravans_sidebar() {
get_sidebar( 'caravans-sidebar' );
}Can anyone please help me? I'm so close...
thank you
http://162.144.99.26/~sacrealtNovember 14, 2014 at 10:55 pm #131588WisdmLabs
MemberHi,
Try the below codegenesis_register_sidebar( array( ‘id’ => ‘‘caravans-sidebar’, ‘name’ => ‘Caravans Sidebar’, ‘description’ => ‘This is the caravans sidebar widget area.’ ) ); add_action('get_header','trestle_sidebar_logic'); function trestle_sidebar_logic() { if ( is_page(3747) ) { remove_action( 'genesis_sidebar', 'genesis_do_sidebar' ); add_action( 'genesis_sidebar', 'trestle_get_caravans_sidebar' ); } } function trestle_get_caravans_sidebar() { genesis_widget_area( 'caravans-sidebar' ); }
November 17, 2014 at 9:51 am #131855jmamuzich
MemberThat worked perfectly! Thank you so much 🙂
November 17, 2014 at 10:54 am #131867jmamuzich
MemberSorry I have one more question: If I need to register additional sidebars of the same type, how would I do so? I realized I need different information for my caravans sections and there are 6 different ones - so I guess I need a separate sidebar for each. I tried registering them using the same type of code with different names and the different page #'s but it wasn't right because I couldn't access the widget area in the backend anymore - just the white screen of death.
thanks
November 17, 2014 at 4:30 pm #131907jmamuzich
MemberOk I got it to register two different sidebars so far. However, the primary sidebar is still showing on one of the pages and I'm not sure why. This is the code i have:
//* Register new sidebar for the blog and posts genesis_register_sidebar( array( 'id' => 'custom-blog-sidebar', 'name' => 'Custom Blog Sidebar', 'description' => 'This is the sidebar for the Blog', ) ); add_action('get_header','custom_blog_sidebar'); function custom_blog_sidebar() { if ( is_home() || is_archive() || is_single() ) { remove_action( 'genesis_sidebar', 'genesis_do_sidebar' ); add_action( 'genesis_sidebar', 'do_sidebar' ); } } function do_sidebar() { genesis_widget_area( 'custom-blog-sidebar' ); } // Register a new sidebar for Arden Caravan genesis_register_sidebar( array( 'id' => 'arden-sidebar', 'name' => 'Arden Sidebar', 'description' => 'This is the arden caravans sidebar widget area' ) ); add_action('get_header','trestle_sidebar_logic'); function trestle_sidebar_logic() { if ( is_page('3747') ) { remove_action( 'genesis_sidebar', 'genesis_do_sidebar' ); add_action( 'genesis_sidebar', 'trestle_get_arden_sidebar' ); } } function trestle_get_arden_sidebar() { genesis_widget_area( 'arden-sidebar' ); } // Register a new sidebar for Carmichael Caravan genesis_register_sidebar( array( 'id' => 'carmichael-sidebar', 'name' => 'Carmichael Sidebar', 'description' => 'This is the carmichael caravans sidebar widget area' ) ); add_action('get_header','trestle_sidebar_carmichael'); function trestle_sidebar_carmichael() { if ( is_page('3769') ) { remove_action( 'genesis_sidebar', 'genesis_do_sidebar', 'do_sidebar', 'trestle_get_arden_sidebar' ); add_action( 'genesis_sidebar', 'trestle_get_carmichael_sidebar' ); } } function trestle_get_carmichael_sidebar() { genesis_widget_area( 'carmichael-sidebar' ); }
I need to register 4 or 5 sidebars similar to the carmichael and arden ones.
Any help is greatly appreciated!
November 17, 2014 at 4:39 pm #131911jmamuzich
MemberChanged
remove_action( 'genesis_sidebar', 'genesis_do_sidebar', 'do_sidebar', 'trestle_get_arden_sidebar' );
To
remove_action( 'genesis_sidebar', 'genesis_do_sidebar' );now it works 🙂
-
AuthorPosts
- The forum ‘General Discussion’ is closed to new topics and replies.