这是一种很有技巧的方法来完成这一点,但深入研究核心发现默认的节名是header_image
:
https://core.trac.wordpress.org/browser/tags/3.5.1/wp-includes/class-wp-customize-control.php#L734
因此,如果我们将要添加到的部分命名为
header_image
, 这个
custom-header
设置将自动应用于该节。例如:
$wp_customize->add_panel(
\'example_panel\',
array(
\'priority\' => 10,
\'capability\' => \'edit_theme_options\',
\'theme_supports\' => \'\',
\'title\' => __( \'Example Panel\', \'textdomain\' ),
\'description\' => __( \'Description of what this panel does.\', \'textdomain\' ),
)
);
$wp_customize->add_section(
\'header_image\',
array(
\'title\' => __( \'Slider Images\', \'textdomain\' ),
\'description\' => __( \'This is a section for the slider images.\', \'textdomain\' ),
\'priority\' => 10,
\'panel\' => \'example_panel\',
)
);
/* Header Image controls will load here */
将显示标题图像控件,您可以继续在面板中添加其他设置:
$wp_customize->add_control(
\'example_text\',
array(
\'label\' => __( \'Example Text\', \'textdomain\' ),
\'section\' => \'header_image\',
\'type\' => \'text\',
\'panel\' => \'example_panel\'
)
);