WordPress customizer multiple add_control ‘s in section

Quick question.

I’m trying to add multiple controls within a WordPress customizer section.

Read More
$wp_customize->add_section( 'lr_panel2', array(
        'title'           => esc_html__( 'Panel 2', 'lr' ),
        'active_callback' => 'is_front_page',
        'panel'           => 'lr_theme_options',
        'description'     => esc_html__( 'Add a background image to your panel by setting a featured image in the page editor. If you don’t select a page, this panel will not be displayed.', 'lr' ),
    ) );

    $wp_customize->add_setting( 'lr_panel2', array(
        'default'           => false,
        'sanitize_callback' => 'lr_sanitize_numeric_value',
    ) );

    $wp_customize->add_control( 'lr_panel2', array(
        'label'   => esc_html__( 'Panel Content', 'lr' ),
        'section' => 'lr_panel2',
        'type'    => 'dropdown-pages',
    ) );

So this one is working fine and dandy. I try to add a second one and neither render. I assumed I could just repeat the add_control class, something like:

$wp_customize->add_control( 'lodestar_panel2', array(
        'label'   => esc_html__( 'Panel Layout', 'lr' ),
        'section' => 'lr',
        'type'    => 'select',
        'choices' => array(

            ),
    ) );

But that’s not working how I want it too, Has anyone done this before?

Thanks!

Related posts

1 comment

  1. You are adding the control in another section. Section should be same

    'section' => 'lr_panel2',
    

    This is the section of first control you’ve added and

    'section' => 'lr',
    

    This is the section of second control you’ve added

    Also a control wouldn’t show unless you’ve added somethings in it.

Comments are closed.