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 a WordPress Expert

Get hourly and project based theme customization, theme tweaks, and development help from world-class WordPress developers at Codeable. If you’re in Kelowna and need a custom website for your business visit our Kelowna Web Design page now to get started.