Community Forums › Forums › Archived Forums › Design Tips and Tricks › custom sidebar to use in a new page template
- This topic has 5 replies, 4 voices, and was last updated 9 years, 10 months ago by Toon61.
-
AuthorPosts
-
January 8, 2014 at 1:46 pm #84055BillParticipant
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 #84834Dorian SpeedMemberTry 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 #84896BillParticipantThanks 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 #85492BillParticipantDoes 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 #86549lagomdesignMemberI'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 #109340Toon61MemberBill,
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.
-
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.