0

I want to return the value of get_background_color but that value isn't showing up.

<?php echo get_background_color(); ?>

I have colors enabled in my customizer, and there is the option 'background color', so I'm kinda confused about this option.


And also, how can I add a colorpicker option in the customizer so I can remove the colors section? I have tried:

$wp_customize->add_setting('bgcolor');
$wp_customize->add_control('bgcolor', array(
    'label'   => 'Background color',
    'section' => 'themeoptions',
    'type'    => 'color-picker',
));

and

$wp_customize->add_setting('bgcolor');
$wp_customize->add_control('bgcolor', array(
    'label'   => 'Background color',
    'section' => 'themeoptions',
    'type'    => 'color',
));

but with the above example the customizer goes blank.

Thanks in advance.

0

To add custom background support in your theme you need to register the default custom background support.

Example:-

add_action('after_setup_theme', function(){
    add_theme_support( 'custom-background', array( 
        'default-color' => 'black' //Default color 
    )); 
});

Now you will see a new section Background Image in customizer and in Color you will see a new option Background color

Once you will save the settings you can use echo get_background_color();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.