Add Customizer to WordPress Theme

Add a customizer to your WordPress website with this code snippet.

Add a Customize link to the backend of your WordPress Admin area that lets users add customize the theme easily.


// Theme customizer sample
add_action('admin_menu', 'em_customizer_link_example');
function em_customizer_link_example() {
	add_theme_page('Customize', 'Customize', 'edit_theme_options', 'customize.php');
}
add_action('customize_register', 'em_customizer_example');
function em_customizer_example($wp_customize){
	$wp_customize->add_section('em_customizer_settings', array(
		'title' => 'Example Settings',
		'priority' => 35,
		)
	);
	$wp_customize->add_setting('background_setting', array(
		'default' => '#ffffff',
		)
	);
	$wp_customize->add_control(new WP_Customize_Color_Control( $wp_customize, 'background_setting', array(
		'label' => 'Background Color',
		'section' => 'em_customizer_settings',
		'settings' => 'background_setting',
		)
		)
	);
	$wp_customize->add_setting('footer_text', array(
		'default' => 'WordPress Demonstration Theme using the em CSS Framework',
		)
		);
	$wp_customize->add_control('footer_text', array(
		'label' => 'Footer Text',
		'section' => 'em_customizer_settings',
		'type' => 'text',
		)
		);
}

Hire WordPress Experts at Codeable.

The only WordPress exclusive freelancer platform that connects thousands of customers with the top WordPress freelance experts to work on projects of any size. 

Free estimate • No obligation to hire • 100% risk-free