快速提问。
我正在尝试在WordPress自定义程序部分添加多个控件。
$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',
) );
所以这个工作正常,花花公子。我尝试添加第二个并且都不渲染。我假设我可以重复add_control类,例如:
$wp_customize->add_control( 'lodestar_panel2', array(
'label' => esc_html__( 'Panel Layout', 'lr' ),
'section' => 'lr',
'type' => 'select',
'choices' => array(
),
) );
但是这也不是我想要的,有人之前做过这个吗?
谢谢!
答案 0 :(得分:0)
您正在另一部分添加控件。部分应该相同
'section' => 'lr_panel2',
这是您添加的第一个控件的部分
'section' => 'lr',
这是您添加的第二个控件的部分
除非您在其中添加了某些内容,否则控件也不会显示。