WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

i am trying to figure out how to use more that one image upload in the same section in theme customizer.

the function is new WP_Customize_Image_Control. when you try to get the path of the image you have uploaded it will give you only from the first WP_Customize_Image_Control you have created. the others just not working.

this is the code:

$wp_customize->add_section(
    'head_section',
    array(
        'title' => 'Head',
        'description' => 'head section.',
        'priority' => 55,
    )
);

$wp_customize->add_setting( 'img-upload' );

$wp_customize->add_control(
    new WP_Customize_Image_Control(
        $wp_customize,
        'first-img-upload',
        array(
            'label' => 'first image Upload',
            'section' => 'head_section',
            'settings' => 'img-upload'
        )
    )
);

$wp_customize->add_setting( 'img-upload' );

$wp_customize->add_control(
    new WP_Customize_Image_Control(
        $wp_customize,
        'second-img-upload',
        array(
            'label' => 'second image Upload',
            'section' => 'head_section',
            'settings' => 'img-upload'
        )
    )
);

then i try to get the link to the image by using

$first_image = get_theme_mod('first-img-upload');
$second_image = get_theme_mod('second-img-upload');
echo $first_image;
echo $second_image;

from here i just get the first link but the secend is empty.

thanks for help.

share|improve this question
    
Can you edit your question to include your customizer code? – sabreuse Oct 2 '13 at 19:59
    
Hello @sabreuse i have update my quasion and add the code from Customizer. so when i try to get the url from the first and the secend image i just get only from the first upload. – need-help Oct 5 '13 at 5:41
    
You're trying to assign two different settings to the same ID. Try it with $wp_customize->add_setting( 'first-img-upload' ); and $wp_customize->add_setting( 'second-img-upload' ); – sabreuse Oct 6 '13 at 20:44

You have to add more than one setting. Change

$wp_customize->add_setting( 'img-upload' ); 

to two unique settings. i.e. img-upload-1, img-upload-2. Then call the settings in your code.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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