How to print the value of a custom control in the Customizer?

Your code is perfect just need to change 'theme_mod' instead of 'option' it will solve this.

function themename_customize_register($wp_customize){
        $wp_customize->add_setting( 'test_setting', array(
            'default'        => 'value_xyz',
            'capability'     => 'edit_theme_options',
            'type'           => 'theme_mod',
        ));
        $wp_customize->add_control( 'test_control', array(
            'label'      => __('Text Test', 'themename'),
            'section'    =>  'spacious_slider_number_section1',
            'settings'   => 'test_setting',
        ));
}
add_action('customize_register', 'themename_customize_register');

And to retrieve it

get_theme_mod( 'test_setting' ); 

Hope it helps you out.

Leave a Comment