Dynamically change feature image in customiser

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 Comment