How to remove default sections/panels in WordPress customizer

WordPress customizer has several default sections/panels here appearance > customize. While these provide you an option to quickly add settings/options for your theme, they also clutter up the space and in some custom themes these sections/panels may not be required at all.

This guide shows you how to remove default sections/panels from customize screen.

The customize screen on WordPress consists of sections, panels, controls and settings.

Sections, panels and controls are UI elements – which means you can see the elements on screen as parts of layouts and inputs. Settings is not an UI element – it is a value that is saved in database and is manipulated through a control.

To remove a section/panel you need the id of that section/panel. Next you need to know if the item you want to remove is a section or a panel (because it is not obvious from outside which item is a section and which one is a panel ). Then it can be removed through a simple call to remove_section or remove_panel using the customize manager object as shown below –

$wp_customize->remove_section('header_image');

Where $wp_customize is the customize manager object, remove_section is the call to remove a section with id header_image.

To remove a panel you would use the following code

$wp_customize->remove_panel('nav_menus');

Here nav_menus is the panel id.

So where do you put this code? Put this code in a callback function numag_remove_sections for the action hook customize_register. You can change the name of this callback function to suit your needs.

This is how the callback function looks like

function numag_remove_sections( $wp_customize ) {

	$wp_customize->remove_section('header_image');
	$wp_customize->remove_panel('nav_menus');
	//$wp_customize->remove_panel('widgets');
	//$wp_customize->remove_section('custom_css');	
	//$wp_customize->remove_section('colors');
	//$wp_customize->remove_section('background_image');
	//$wp_customize->remove_section('static_front_page');	 
	//$wp_customize->remove_section('title_tagline');	
}
add_action( 'customize_register', 'numag_remove_sections');

For your convenience I have added code to remove all the default sections and panels. Just un-comment the respective line.

This is how the customize screen looks like now:

Did that work for you. Any other methods to achieve the same result? Share with us in the comments below.