• 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

How to customize sidebars by page

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 › How to customize sidebars by page

This topic is: not resolved

Tagged: Sidebar, templates, widgets

  • This topic has 3 replies, 2 voices, and was last updated 9 years, 10 months ago by cutcopypaste.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • November 7, 2013 at 10:19 am #71490
    cutcopypaste
    Member

    I am trying to remove the primary-sidebar widget area (which contains the search, and the Primary widget) from certain pages, but keep other widgets etc.

    this is the code I have so far:

    //ADD CATEGORIES IN SIDEBAR OF SINGLE POST TYPE
    add_action( 'genesis_sidebar', 'add_mysite_sidebar' );
    function add_mysite_sidebar() {
    	if( get_post_type() == 'post' ){		
    		dynamic_sidebar( 'News Categories' );
    	} else if( get_post_type() == 'events' ){		
    		dynamic_sidebar( 'Event Categories' );
    	} else if( get_post_type() == 'documentlibrary' ){		
    		dynamic_sidebar( 'Document Categories' );
    	} else if( get_post_type() == 'bp_members' ){
    		include(members_sidebar.php);
    		unregister_sidebar( 'sidebar' );
    		dynamic_sidebar( 'Members Widget' );
    	} else if( get_post_type() == 'bp_group' ){	
    		include(groups_sidebar.php);
    		unregister_sidebar( 'sidebar' );	
    		dynamic_sidebar( 'Groups Widget' );
    	}
    }

    I'm concerned about the bp_members and bp_group sections.. the unregister sidebar doesn't work I suspect because it's already registered once it's in this action, but I hope you can see what I'm trying to do!

    I tried to hide it with CSS but the widgets contained in the Primary widget area don't seem to have their own targetable css rules.. I am developing locally so can't include a url unfortunately

    November 7, 2013 at 1:29 pm #71524
    nutsandbolts
    Member

    You could try the Widget Context plugin - it lets you decide where certain widgets show up on an individual basis. If you'd rather have different sidebars on different pages, try the Genesis Simple Sidebars plugin.


    Andrea Whitmer, Owner/Developer, Nuts and Bolts Media
    I provide development and training services for designers • Find me on Twitter and Google+

    November 7, 2013 at 2:40 pm #71539
    cutcopypaste
    Member

    Thank you for the suggestion. I'm looking for a simple way with code since that's where my other widget assignments are.. I don't want to have some in the database and some in the php..

    November 11, 2013 at 9:48 am #72314
    cutcopypaste
    Member

    I fixed it with this code:

    add_action( 'genesis_after_header', mysite_bpress_sidebars' );
    function mysite_bpress_sidebars(){
    	if( get_post_type() == 'bp_members' ){
    		remove_action( 'genesis_sidebar', 'genesis_do_sidebar' );
    		dynamic_sidebar( 'Members Widget' );
    	} else if( get_post_type() == 'bp_group' ){	
    		remove_action( 'genesis_sidebar', 'genesis_do_sidebar' );
    		dynamic_sidebar( 'Groups Widget' );
    	}
    }
  • Author
    Posts
Viewing 4 posts - 1 through 4 (of 4 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

© 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