How to add a logo uploading field in customize settings in wordpress

How to add a logo uploading field in theme customize settings in wordpress

While creating our own theme, we need to add a logo adding field in in customize settings of theme (under appearance).

add_action( ‘customize_register‘, ‘themecustomizer’ );

function themecustomizer( $wp_customize ) {
$wp_customize->add_section( ‘theme_logo’ , array(
‘title’ => __( ‘Logo’, ‘theme’ ),
‘priority’ => 30,
‘description’ => ‘Upload a logo’,
) );
$wp_customize->add_setting( ‘theme_logo’ );
$wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, ‘theme_logo’, array(
‘label’ => __( ‘Logo’, ‘theme’ ),
‘section’ => ‘theme_logo’,
‘settings’ => ‘theme_logo’,
) ) );

}

https://codex.wordpress.org/Plugin_API/Action_Reference/customize_register