I have added a section in my customizer to upload a background image for my main site. I am calling it here:

background:url('<?php echo get_theme_mod( 'header_image_uploaded', 'http://www.unitedwayofmilford.org/wp-content/uploads/2020/03/Canva-Lending-a-helping-hand..jpg' ); ?>') no-repeat center center fixed;

It is not showing up.

Here is the code for my customizer functions

function uwm_customize_register( $wp_customize ) {

$wp_customize->add_setting( 'header_image' , array(
'default'   => 'http://www.unitedwayofmilford.org/wp-content/uploads/2020/03/Canva-Lending-a-helping-hand.jpg',) );

$wp_customize->add_section( 'main_header_image' , array(
'title'      => __( 'Choose Your Main Image', 'uwm' ),) );

new WP_Customize_Upload_Control( 
    'label'      => __( 'Main Image Upload', 'uwm' ),
    'section'    => 'main_header_image',
    'settings'   => 'header_image',) ) );
}add_action( 'customize_register', 'uwm_customize_register' );

Any help would be greatly appreciated.


1 Answer 1


The value of the field will be the ID of the uploaded attachment. Not an image URL. You will need to use wp_get_attachment_image_url() to get the URL.

echo wp_get_attachment_image_url( get_theme_mod( 'header_image_uploaded' ), 'full' );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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