• 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

custom sidebar to use in a new page template

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 › Design Tips and Tricks › custom sidebar to use in a new page template

This topic is: not resolved
  • This topic has 5 replies, 4 voices, and was last updated 12 years, 1 month ago by Toon61.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • January 8, 2014 at 1:46 pm #84055
    Bill
    Participant

    I want to use a specific custom sidebar on a particular page template. I am using widget logic currently to include or exclude widgets in the primary sidebar based on a page template conditional. ...., but I now want to eliminate widget logic altogether.

    I added the following code to my new page template, and although it does add the new sidebar to my page, it does not delete the existing primary sidebar. It just puts the new sidebar above the primary sidebar.
    Can I not remove the primary sidebar from the new page template in the manner below? Thanks for any insight in advance.

    //Add custom sidebar for my page template
       remove_action( 'genesis_sidebar', 'genesis_do_sidebar' ); //remove the default genesis sidebar
       add_action( 'genesis_sidebar', 'my_do_sidebar' ); //add an action hook to call the function for my custom sidebar
    
    //Function to output my custom sidebar
    function my_do_sidebar() {
    	dynamic_sidebar( 'my-new-sidebar' );
    }
    
    genesis();
    January 12, 2014 at 4:35 pm #84834
    Dorian Speed
    Member

    Try this instead:

    //Use a different sidebar on this page template
    add_action('get_header','ds_change_genesis_sidebar');
    function ds_change_genesis_sidebar() {
            remove_action( 'genesis_sidebar', 'genesis_do_sidebar' ); //remove the default genesis sidebar
            add_action( 'genesis_sidebar', 'ds_do_sidebar' ); //add an action hook to call the function for my custom sidebar
    }
    
    //Function to output my custom sidebar
    function ds_do_sidebar() {
    	dynamic_sidebar( 'my-new-sidebar' );
    }

    Here's a related tutorial from Carrie Dils:
    http://www.carriedils.com/sidebar-custom-post-type/


    Bringing websites Up to Speed
    Firebug will light the way to understanding the secrets of the Internet!

    January 12, 2014 at 9:22 pm #84896
    Bill
    Participant

    Thanks for the response Dorian! I tried this, and I get the same thing as my code. I still have the original primary sidebar, and then underneath all the widgets from the primary sidebar I get the new widgets from the new sidebar. For some reason the primary sidebar is not removing. I am using and html5 mod of the education theme. (if that makes any difference) I dont think it would though.

    I could use simple sidebars as well (as I do use it on this site already, but the catch is I need to call the simple sidebar based on the page template. not sure the conditional to do that..... that is why I was trying to just put this code above in the actual page template itself. hope that makes sense.

    January 16, 2014 at 8:48 am #85492
    Bill
    Participant

    Does anyone have a suggestion for this? The remove action is not working.

    //Add custom sidebar for my page template
    remove_action( 'genesis_sidebar', 'genesis_do_sidebar' ); //remove the default genesis sidebar
    add_action( 'genesis_sidebar', 'my_do_sidebar' ); //add an action hook to call the function for my custom sidebar
    //Function to output my custom sidebar
    function my_do_sidebar() {
    dynamic_sidebar( 'new-sidebar' );
    }

    I have tried variations of this code. I have a new page template, and i am using this code in that template with the goal of deleting the primary sidebar on these pages, and adding a new sidebar on these pages. This code is adding the new sidebar on this template page successfully.... but it NOT removing the primary sidebar. The Primary sidebar is just below the new sidebar. I can't understand why.

    I am using the education theme that was changed to html 5

    NOTE: I already use simple sidebars for other things on this site, but I need to target this page template specifically for new sidebars. That is why I need to accomplish this from the page template side of things rather than "just use simple sidebars". As far as I know, you cant use simple sidebars to target a page template unless you use the primary sidebar, and use widget logic plugin to target the page template with a conditional statement....and I don't want to do that for other reasons. WHy is the primary sidebar not getting removed?

    January 22, 2014 at 4:08 pm #86549
    lagomdesign
    Member

    I'm actually having a similar problem with the Education Theme. I cannot get many elements to remove using the normal methods. For example, adding
    remove_action( 'genesis_after_post_content', 'genesis_post_meta' );
    has yet to remove the post_meta. I've tried it on a Custom Post Type archive page. For kicks I put in the theme's functions.php. But no effect anywhere.
    I feel your pain, billmcq.

    June 11, 2014 at 6:02 am #109340
    Toon61
    Member

    Bill,

    I don't know why the 'default' sidebar (Primary Sidebar) won't go away (I'm having the same issue at the moment).
    I added the custom sidebar in my page PHP file, like you did.
    And I made a simple CSS rule like this:
    body.archive aside.sidebar section.widget.featuredpost {display: none;}
    This is not the most elegant way of 'deleting' a sidebar, but it works (the css depends on the widget(s) you have placed on the 'Primary Sidebar').

    Or have you found a better solution in the meantime.

  • Author
    Posts
Viewing 6 posts - 1 through 6 (of 6 total)
  • The forum ‘Design Tips and Tricks’ 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

© 2026 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