custom sidebar to use in a new page template

Community Forums Forums Design Tips and Tricks custom sidebar to use in a new page template

This topic is: not resolved

This topic contains 5 replies, has 4 voices, and was last updated by  Toon61 5 months, 2 weeks ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #84055

    billmcq
    Participant
    Post count: 29

    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();
    • This topic was modified 10 months, 3 weeks ago by  billmcq.
    • This topic was modified 10 months, 3 weeks ago by  billmcq.
    #84834

    Dorian Speed
    Participant
    Post count: 140

    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!

    #84896

    billmcq
    Participant
    Post count: 29

    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.

    #85492

    billmcq
    Participant
    Post count: 29

    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?

    #86549

    lagomdesign
    Participant
    Post count: 3

    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.

    #109340

    Toon61
    Participant
    Post count: 49

    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.

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.