How to customize sidebars by page

Community Forums Forums Design Tips and Tricks How to customize sidebars by page

This topic is: not resolved

This topic contains 3 replies, has 2 voices, and was last updated by  cutcopypaste 8 months, 2 weeks ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #71490

    cutcopypaste
    Participant
    Post count: 7

    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

    #71524

    nutsandbolts
    Moderator
    Post count: 3113

    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, Nuts and Bolts Media
    I provide dev and training services for web designers • Find me on Twitter and Google+

    #71539

    cutcopypaste
    Participant
    Post count: 7

    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..

    #72314

    cutcopypaste
    Participant
    Post count: 7

    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' );
    	}
    }
Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.