• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

Registering additional sidebar

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

Community Forums › Forums › Archived Forums › General Discussion › Registering additional sidebar

This topic is: resolved

Tagged: custom sidebar, Sidebar

  • This topic has 5 replies, 2 voices, and was last updated 8 years, 4 months ago by jmamuzich.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • November 14, 2014 at 6:22 pm #131578
    jmamuzich
    Member

    Hello,

    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/~sacrealt
    November 14, 2014 at 10:55 pm #131588
    WisdmLabs
    Member

    Hi,
    Try the below code

    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_sidebar', 'genesis_do_sidebar' );
            add_action( 'genesis_sidebar', 'trestle_get_caravans_sidebar' );
        }
    }
    
    function trestle_get_caravans_sidebar() {
    	genesis_widget_area( 'caravans-sidebar' );
    }

    http://wisdmlabs.com/

    November 17, 2014 at 9:51 am #131855
    jmamuzich
    Member

    That worked perfectly! Thank you so much 🙂

    November 17, 2014 at 10:54 am #131867
    jmamuzich
    Member

    Sorry 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 #131907
    jmamuzich
    Member

    Ok 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 #131911
    jmamuzich
    Member

    Changed
    remove_action( 'genesis_sidebar', 'genesis_do_sidebar', 'do_sidebar', 'trestle_get_arden_sidebar' );
    To
    remove_action( 'genesis_sidebar', 'genesis_do_sidebar' );

    now it works 🙂

  • Author
    Posts
Viewing 6 posts - 1 through 6 (of 6 total)
  • The forum ‘General Discussion’ is closed to new topics and replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2023 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble