0

I'm trying to build up a multi sections Customizer in wordpress and when i add the third section in a single panel the first section is set to display: none don't know what seems to be the issue. If any one can guide me where i'm doing things wrong, thanks in advance.

Steps to reproduce the issue:

Customizer.php inside inc folder in my theme.

<?php
/**
 * GYM: Customizer
 *
 * @package WordPress
 * @subpackage GYM
 * @since GYM 1.0
 */

 /*
   Including Customization Support 
*/

function mytheme_customize_register( $wp_customize ) {
   //All our sections, settings, and controls will be added here

    $wp_customize->add_panel('panel_id',array(
        'panel'=>'panel_id',
        'title'=>__('Theme Options'),
        'priority'=>10,
    ));

    // Sections here.
    $wp_customize->add_section( 'mytheme_new_section_name' , array(
        'panel' => 'panel_id',
    'title'      => __( 'Visible Section Name', 'mytheme' ),
    'priority'   => 10,
    ) );

    $wp_customize->add_section('mytheme_new_section', array(
        'panel' => 'panel_id',
        'title' => __('Second Section Name', 'mytheme'),
        'priority' => 20,
    ));

    $wp_customize->add_section('mytheme_new_new_section', array(
        'panel' => 'panel_id',
        'title' => __('Third Section Name', 'mytheme'),
        'priority' => 30,
    ));



    // First Section.
        $wp_customize->add_setting(
        'primary_color',
        array(
            'default'           => 'default',
            'transport'         => 'postMessage',
            'sanitize_callback' => 'twentynineteen_sanitize_color_option',
        )
    );

    $wp_customize->add_control(
        'primary_color',
        array(
            'type'     => 'radio',
            'label'    => __( 'Primarys Color', 'twentynineteen' ),
            'choices'  => array(
                'default' => _x( 'Default', 'primary color', 'twentynineteen' ),
                'custom'  => _x( 'Custom', 'primary color', 'twentynineteen' ),
            ),
            'section'  => 'mytheme_new_section',
            'priority' => 5,
        )
    );

    // Second Section 
        $wp_customize->add_setting(
        'primary_colors',
        array(
            'default'           => 'default',
            'transport'         => 'postMessage',
            'sanitize_callback' => 'twentynineteen_sanitize_color_option',
        )
    );

    $wp_customize->add_control(
        'primary_colors',
        array(
            'type'     => 'radio',
            'label'    => __( 'Primary Text Color', 'gym' ),
            'choices'  => array(
                'default' => _x( 'Default', 'primary color', 'gym' ),
                'custom'  => _x( 'Custom', 'primary color', 'gym' ),
            ),
            'section'  => 'mytheme_new_section_name',
            'priority' => 5,
        )
    );

    //Third Section
    $wp_customize->add_setting(
        'primary_colors',
        array(
            'default'           => 'default',
            'transport'         => 'postMessage',
            'sanitize_callback' => 'twentynineteen_sanitize_color_option',
        )
    );

    $wp_customize->add_control(
        'primary_colors',
        array(
            'type'     => 'radio',
            'label'    => __( 'Primary Updated Text Color', 'gym' ),
            'choices'  => array(
                'default' => _x( 'Default', 'primary color', 'gym' ),
                'custom'  => _x( 'Custom', 'primary color', 'gym' ),
            ),
            'section'  => 'mytheme_new_new_section',
            'priority' => 5,
        )
    );
}
add_action( 'customize_register', 'mytheme_customize_register' );

Here's the result in customizer Options. I'm not able to see the first section " Visible Section Name" in the list.

enter image description here

2
  • 1
    You’ve used the same ID for the last two controls. This means that only the last one will be used, which means that there are no controls registered for the first section, so it won’t appear. Commented Jul 15, 2020 at 11:06
  • Thanks problem solved. Commented Jul 15, 2020 at 11:09

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.