Hello reader's today we discuss about "Add logo in theme customize option" in wordpress.
Open your function.php and paste the below code :-
/**
 * Add logo in theme customize option
 */
add_action( 'customize_register', 'themename_customize_register' );
function themename_customize_register($wp_customize) {
    $wp_customize->add_section( 'ignite_custom_logo', array(
        'title'              => 'Logo',
        'description'        => 'Display a custom logo?',
        'priority'           => 25,
    ) );
    $wp_customize->add_setting( 'custom_logo', array(
        'default'            =>; '',
    ) );
    $wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'custom_logo', array(
        'label'             => 'Custom logo',
        'section'             => 'ignite_custom_logo',
        'settings'            => 'custom_logo',
    ) ) );
}
Now open your header.php file and put the below code in place of logo image :-
<img src="<?php echo esc_url( get_theme_mod( 'custom_logo' ) ); ?>" alt="logo" />
I hope  this help you, thanks.
                       
                    
0 Comment(s)