Multiple sections in Theme Customizer overwritten

I have successfully added a section to the Theme Customizer, can change the header image of a certain page. But now I want to add a different section for another page, but the first section is always overwritten.. The ID’s should be well linked.

<?php

function af_customize_register($wp_customize){

  // header image section

  $wp_customize->add_setting('front_header_image', array(
    'default' => 'http://******.be/wp-content/uploads/2017/04/about-header-1200.jpg',
    'transport' => 'refresh'
  ));

  $wp_customize->add_section('front_header_image_section', array(
    'title' => 'Frontpage Header',
    'description' => 'Add an image to the front page.',
    'priority' => '1'
  ));

  $wp_customize->add_control(
       new WP_Customize_Image_Control(
           $wp_customize,
           'image',
           array(
               'label'      => 'Upload image to the frontpage',
               'section'    => 'front_header_image_section',
               'settings'   => 'front_header_image'
           )
       )
   );

   // archive image section
   $wp_customize->add_setting('archive_header_image', array(
     'default' => 'http://******.be/wp-content/uploads/2017/04/about-header-1200.jpg',
     'transport' => 'refresh'
   ));

   $wp_customize->add_section('archive_header_image_section', array(
     'title' => 'Archive Headers',
     'description' => 'Add an image to an archive page.',
     'priority' => '10'
   ));

   //
   $wp_customize->add_control(
        new WP_Customize_Image_Control(
            $wp_customize,
            'image',
            array(
                'label'      => 'Upload image to archive page',
                'section'    => 'archive_header_image_section',
                'settings'   => 'archive_header_image'
            )
        )
    );

}

?>

Read more here: Multiple sections in Theme Customizer overwritten

Leave a Reply

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