I’m trying to add a second background image function to my theme customizer with this code.
// HTML Background Image
$wp_customize->add_setting(
'html_background_image',
array(
'capability' => 'edit_theme_options',
));
$wp_customize->add_control(
new WP_Customize_Background_Image_Control(
$wp_customize,
'background_image',
array(
'label' => __('HTML Background Image', 'TEXTDOMAIN'),
'section' => 'background_image',
'settings' => 'html_background_image',
)));
But it doesn’t work. Am I missing something here?
There’s very little documentation on this class, but here below is the full example from WordPress core (here’s github). Note you’d be using the
$wp_customize
object you get as argument to yourcustom_register
callback and not$this
as does the core class. I’ve done a search and replace below and it works.It appears you cannot customize the e.g. section, and for evidence look to this code for the third argument to WP_Customize_Image_Control