这段代码对我有用
<? php
/**
* Add panel | custom section and settings
*/
function firstest_news_theme_customize_register( $wp_customize ) {
// add panel
// Add Theme Options Panel.
$wp_customize->add_panel( \'theme_option_panel\',
array(
\'title\' => esc_html__( \'Theme Options\', \'wp-firstest-news-theme\' ),
\'priority\' => 20,
\'capability\' => \'edit_theme_options\',
)
);
// Global Section Start.*/
$wp_customize->add_section( \'social_option_section_settings\',
array(
\'title\' => esc_html__( \'Social Profile Options\', \'wp_firstest_news_theme\' ),
\'priority\' => 120,
\'capability\' => \'edit_theme_options\',
\'panel\' => \'theme_option_panel\', //Refence to panel above
)
);
/*Social Profile*/
$wp_customize->add_setting( \'social_profile\',
array(
\'default\' => $default[\'social_profile\'],
\'capability\' => \'edit_theme_options\'
// \'sanitize_callback\' => \'wp_firstest_news_theme_sanitize_checkbox\',
)
);
$wp_customize->add_control( \'social_profile\',
array(
\'label\' => esc_html__( \'Global Social Profile ( Nav Right )\', \'wp-firstest-news-theme\' ),
\'section\' => \'social_option_section_settings\',
\'type\' => \'checkbox\',
)
);
// Global section start **************************
$wp_customize->add_section(\'theme-option\', array(
\'title\' => __(\'Edit Carousel\', \'wp-firstest-news-theme\'),
\'description\' => sprintf(__(\'Options for showcase\', \'wp-firstest-news-theme\')),
\'priority\' => 130,
\'capability\' => \'edit_theme_options\',
\'panel\' => \'theme_option_panel\'
));
// Add image slider
$wp_customize->add_setting(\'slider_1_image\', array(
\'default\' => get_bloginfo(\'template_directory\') . \'/img/shocase1.jpg\', \'wp-firstest-news-theme\',
\'type\' => \'theme_mod\'
));
// Add control
$wp_customize->add_control(new WP_Customize_Image_Control($wp_customize, \'slider_1_image\', array(
\'label\' =>esc_html( __(\'Slider Image 1\', \'wp-firstest-news-theme\')),
\'section\' => \'theme-option\',
\'setting\' => \'slider_1_image\',
\'priority\' => 1
)));
// Add settings slider 1 heading
$wp_customize->add_setting(\'showcase_1_heading\', array(
\'default\' => _x(\'Another example headline.\', \'wp-firstest-news-theme\'),
\'type\' => \'theme_mod\'
));
// Add control
$wp_customize->add_control(\'showcase_1_heading\', array(
\'label\' => esc_html(__(\'heading\', \'wp-firstest-news-theme\')),
\'section\' => \'theme-option\',
\'priority\' => 2
));
}
add_action( \'customize_register\', \'firstest_news_theme_customize_register\' );
?>