1

I'm trying to replicate the WordPress core background image customizer settings where the styling settings/controls only appear when an image is uploaded, but can't find a way around it. Is there a hook of any sort to doing this?

$wp_customize->add_setting(
    'custom_background_size',
    array(
        'default'           => 'auto',
        'sanitize_callback' => '',
    )
);
$wp_customize->add_control(
    'custom_background_size',
    array(
        'label' => 'Background Size',
    'section' => 'background_image',
    'type' => 'radio',
    'choices' => array(
      'auto' => 'Auto (default)',
      'cover' => 'Cover'
    )
)
);

I've added a new custom setting/control for the background image size styling to the section . But doing only this will have it appear with or without an image uploaded.

Any help is really appreciated guys. Thanks!

Your Answer

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

Browse other questions tagged or ask your own question.