Customizer API and add_panel(). Panel doesn’t show

I try to add panel to my customizer but code below doesn’t work (panel don’t show in customizer container). My code:

add_action( 'customize_register', 'customizer_test' );
function customizer_test($wp_customize) {
    $wp_customize->add_panel( 'panel_id', array(
        'priority'       => 10,
        'capability'     => 'edit_theme_options',
        'title'          => __('Theme Options', 'mytheme'),
        'description'    => __('Several settings pertaining my theme', 'mytheme'),
    ) );
    //sections
    $wp_customize->add_section( 'header_settings', array(
        'priority'       => 10,
        'capability'     => 'edit_theme_options',
        'title'          => __('Header Settings', 'mytheme'),
        'description'    =>  __('Header elements configuration', 'mytheme'),
        'panel'  => 'panel_id',
    ) );

    $wp_customize->add_section( 'footer_settings', array(
        'priority'       => 10,
        'capability'     => 'edit_theme_options',
        'title'          => __('Footer Settings', 'mytheme'),
        'description'    =>  __('Footer elements configuration', 'mytheme'),
        'panel'  => 'panel_id',
    ) );

}

3 Answers
3

You want to add_setting and add_control to your panel to work.

For example:

function panel($wp_customize){

$wp_customize->add_panel('some_panel',array(
    'title'=>'Panel1',
    'description'=> 'This is panel Description',
    'priority'=> 10,
));


$wp_customize->add_section('section',array(
    'title'=>'section',
    'priority'=>10,
    'panel'=>'some_panel',
));


$wp_customize->add_setting('setting_demo',array(
    'defaule'=>'a',
));


$wp_customize->add_control('contrl_demo',array(
    'label'=>'Text',
    'type'=>'text',
    'section'=>'section',
    'settings'=>'setting_demo',
));}   add_action('customize_register','panel');

Leave a Comment