For this client’s Website I am making on their homepage there is a section called featured products with images showing off the product. Currently I have to update these images manually through my front-page.php file but I don’t want the client to have to do this, I need a custom section in the customiser called something like featureImages and here he can upload his own image that then updates on the front-page. There would have to be 4 upload sections like:

featureImage-1 featureImage-2 featureImage-3 featureImage-4

Then when he uploads a file to either one of them it replaces the currently one with the one he has. I’ve seen this on some themes but I just don’t know how they do it.

I’ve tried searching for this but I don’t really know how to put it into words for Google to give me a result.

I apprentice any help or if you could point me in the right direction if this has been asked before 🙂

1 Answer
1

The customizer has a special control for file uploads. Assuming that you already know how the theme customizer works, you would have to add four controls in this fashion:

$wp_customize->add_control( 
    new WP_Customize_Upload_Control( 
    $wp_customize, 
    'wpse215632_image_1', 
    array(
        'label'       => __( 'First image', 'wpse215632_theme' ),
        'description' => __( 'More about first image', 'wpse215632_theme' ),
        'section'     => 'wpse215632__section_id',
        'settings'    => 'wpse215632__setting_id',
    ) ) 
);

Now, you can retrieve the image in your template with get_theme_mod('wpse215632_image_1').

Leave a Reply

Your email address will not be published. Required fields are marked *