skip to Main Content

Snippet: Alter The Main Sidebar Display

Important: Instead of using code check out the built-in Widget Areas admin panel.
add_filter( 'totaltheme/sidebars/primary/name', 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 child theme's functions.php file or via a plugin (we recommend WPCode)
Back To Top