Custom Sidebars Pro Location

We have a complex News site that hosts University News and Individual Unit News sections. We need to be able to assign sidebars to sections of Pages and Posts for units. However, we can't use categories because we don't want the Individual Unit Category to show up in the list of categories on University level news listings and some posts are displayed in both places. So, is it possible to set the Sidebar Location by a tag or custom taxonomy? We also really don't want to have to custom code the location of each sidebar.

  • Denitsa

    Hello cbenson583,
    I hope you are having a fantastic day and thanks for posting here!

    There is a custom filter that allows you to define your own replacements.

    Here is a usage-example:

    add_filter( 'cs_replace_sidebars', 'my_custom_replacement' );
    function my_custom_replacement( $replacements ) {
    	global $post;
    	if ( /* $post is in section */ ) {
    		$replacements['sidebar-1'] = array(
    			'cs-1', // ID of the custom sidebar to display.
    			'custom', // always 'custom'
    			-1, // always -1
    	return $replacements;

    Where we use 'cs-1' in the example you can use any existing sidebar-ID. All Custom Sidebars will start with 'cs-' (the actual ID is not displayed anywhere, but you can find it in the export-file, or when looking at the page source/network traffic of the widget page, ...). Of course you can also use any theme sidebar-ID for replacement.

    Does it work for you? I can definitely ask one of our SLS (second level support) coding gurus for some feedback here if that's not it, so let me know how it goes :slight_smile:

    All the best,

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.