Snippets: Alter The Main Sidebar Display

add_filter( 'wpex_get_sidebar', function( $sidebar ) {
	// Alter sidebar for single gallery posts
	if ( is_singular( 'gallery' ) ) {
		$sidebar = 'my_custom_sidebar_id';
	}
	// Return sidebar
	return $sidebar;
} );
All PHP snippets should be added via a child theme's functions.php file.