So I have this Custom Section in the Customizer that controls the Feature Products on the Home Page. There all registered and so on but the problem I’m stuck on is when the client uploads one of the feature image I don’t know how to make it update.
functions.php code I’m working with:
// Customiser
function themeName_customize_register( $wp_customize ) {
$wp_customize->add_setting('feature_product_one', array(
'default-image' => get_template_directory_uri() . '/assest/imgs/featureProducts/product1.png',
'transport' => 'refresh',
'height' => 180,
'width' => 160,
));
$wp_customize->add_setting('feature_product_two', array(
'default-image' => get_template_directory_uri() . '/assest/imgs/featureProducts/product1.png',
'transport' => 'refresh',
'height' => 180,
'width' => 160,
));
$wp_customize->add_setting('feature_product_three', array(
'default-image' => get_template_directory_uri() . '/assest/imgs/featureProducts/product1.png',
'transport' => 'refresh',
'height' => 180,
'width' => 160,
));
$wp_customize->add_setting('feature_product_four', array(
'default-image' => get_template_directory_uri() . '/assest/imgs/featureProducts/product1.png',
'transport' => 'refresh',
'height' => 180,
'width' => 160,
));
$wp_customize->add_section('feature_images', array(
'title' => __('Featured Products', 'themeRemax'),
'description' => __('Your 5 Feature Images on the Home-Page.'),
'priority' => 70,
'active_callback' => 'is_front_page',
));
$wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'feature_product_one_control', array(
'label' => __('Feature Product #1', 'themeRemax'),
'section' => 'feature_images',
'settings' => 'feature_product_one',
)));
$wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'feature_product_two_control', array(
'label' => __('Feature Product #2', 'themeRemax'),
'section' => 'feature_images',
'settings' => 'feature_product_two',
)));
$wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'feature_product_three_control', array(
'label' => __('Feature Product #3', 'themeRemax'),
'section' => 'feature_images',
'settings' => 'feature_product_three',
)));
$wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'feature_product_four_control', array(
'label' => __('Feature Product #4', 'themeRemax'),
'section' => 'feature_images',
'settings' => 'feature_product_four',
)));
}
add_action('customize_register', 'themeName_customize_register');
I’ve set the 2 products to have the same default image but when I go into the customizer and update Feature Product #2
it doesn’t update at all.
I know I need to add some code in the front-page inside the <img>
tag but I don’t know what :/
I have a feeling that what I have above is a long winded way to do things but it’s what I got working, if there is an easy way then I would appreciate you pointing me in that direction 🙂
I appreciate any help
Side Note: My front-page.php:
<div class="featureImg">
<img src="https://wordpress.stackexchange.com/questions/215701/What goes here?" alt="Product 1">
<img src="https://wordpress.stackexchange.com/questions/215701/What goes here?" alt="Product 1">
</div>