Riverworks Logo

WordPress Theme Customizer

WordpressCode Snippets

How to add options to the Customizer

(see Furniture Solutions as a working example)

function custom_header( $wp_customize ){
    $wp_customize->add_setting( 'header_logo' );//Setting for logo uploader
    $wp_customize->add_setting( 'phone_number' );
    $wp_customize->add_setting( 'button_text' );
    $wp_customize->add_setting( 'button_link' );

    $wp_customize->add_section(
        'custom_header',
        array(
            'title' => __( 'Custom Header Options' ),
            'priority' => 30,
        )
    );

    $wp_customize->add_control(
        new WP_Customize_Image_Control(
            $wp_customize,
            'header_logo',
            array(
                'label'      => 'Upload a logo',
                'section'    => 'custom_header',
                'settings'   => 'header_logo'
            )
        )
    );
    $wp_customize->add_control(
        new WP_Customize_Control(
            $wp_customize, 'phone_number',
            array(
                'label' => __( 'Phone Number' ),
                'section' => 'custom_header',
                'settings' => 'phone_number'
            )
        )
    );
    $wp_customize->add_control(
        new WP_Customize_Control(
            $wp_customize, 'button_text',
            array(
                'label' => __( 'Button Text' ),
                'section' => 'custom_header',
                'settings' => 'button_text'
            )
        )
    );
    $wp_customize->add_control(
        new WP_Customize_Control(
            $wp_customize, 'button_link',
            array(
                'label' => __( 'Button Link' ),
                'section' => 'custom_header',
                'settings' => 'button_link'
            )
        )
    );
}
add_action('customize_register', 'custom_header');