0

I tried checking and re-checking my code several times to find a flaw, couldn't come up with anything. Then thought it's just like that you can't create different sections under the default "Colors" panel. What I do usually is something like below:

function my_customize_register( $wp_customize ) {
  // Add a Panel
  $wp_customize->add_panel(
    'my_panel',
    array(
      'title'  =>  __( 'My Panel', 'themeslug' ),
      'priority' => 100,
      'description' => __( 'Do something in this panel', 'themeslug' ),
    )
  );

  // Section #1 of our panel
  $wp_customize->add_section(
    'my_panel_sect_1',
    array(
        'title'    => __( 'Section #1', 'themeslug' ),
        'priority' => 10,
        'panel' => 'my_panel',
    )
  );

  $wp_customize->add_setting(
    'sect_1_setting_1',
    array(
        'default'    => '',
        'capability' => 'edit_theme_options',
        'sanitize_callback' => 'sanitize_text_field',
        'transport' => 'postMessage',
    )
  );

  $wp_customize->add_control(
    'sect_1_setting_1',
    array(
      'label'   => __( 'Test control', 'themeslug' ),
      'section' => 'my_panel_sect_1',
      'settings' => 'sect_1_setting_1',
      'type'    => 'text',
    )
  );
  // We can further repeat adding section in this panel like above.
}
add_action( 'customize_register', 'my_customize_register' );

Now if I do try adding section to the default panel called "Colors", I get nothing there.

Please share your thoughts, and what you are doing in order to sectionize the color controls. I guess creating a new panel would help, didn't try it yet.

  • 1
    Colors is a section, not a panel, so you can't add sections to it. – Jacob Peattie Jan 30 '18 at 15:55
  • @JacobPeattie Thanks a lot for sharing this, don't know how I can be this ignorant about it. – Rahul Arora Jan 30 '18 at 15:58
  • No worries, it's not immediately apparent. – Jacob Peattie Jan 30 '18 at 16:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.