根据您的需要:
注册自定义设置,在函数中添加以下代码。php
function themename_customize_register($wp_customize){
$wp_customize->add_section(\'themename_color_scheme\', array(
\'title\' => __(\'Color Scheme\', \'themename\'),
\'priority\' => 120,
));
// =============================
// = Color Picker =
// =============================
$wp_customize->add_setting(\'themename_theme_options[navbar_color]\', array(
\'default\' => \'#000\',
\'sanitize_callback\' => \'sanitize_hex_color\',
\'capability\' => \'edit_theme_options\',
\'type\' => \'option\',
));
$wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, \'navbar_color\', array(
\'label\' => __(\'Link Color\', \'themename\'),
\'section\' => \'themename_color_scheme\',
\'settings\' => \'themename_theme_options[navbar_color]\',
)));
// =============================
// = Text Input =
// =============================
$wp_customize->add_setting(\'themename_theme_options[text_test]\', array(
\'default\' => \'Custom Text!\',
\'capability\' => \'edit_theme_options\',
\'type\' => \'option\',
));
$wp_customize->add_control(\'themename_text_test\', array(
\'label\' => __(\'Text Test\', \'themename\'),
\'section\' => \'themename_color_scheme\',
\'settings\' => \'themename_theme_options[text_test]\',
));
// =============================
// = Image Upload =
// =============================
$wp_customize->add_setting(\'themename_theme_options[image_upload_test]\', array(
\'default\' => \'image.jpg\',
\'capability\' => \'edit_theme_options\',
\'type\' => \'option\',
));
$wp_customize->add_control( new WP_Customize_Image_Control($wp_customize, \'image_upload_test\', array(
\'label\' => __(\'Image Upload Test\', \'themename\'),
\'section\' => \'themename_color_scheme\',
\'settings\' => \'themename_theme_options[image_upload_test]\',
)));
// =============================
// = File Upload =
// =============================
$wp_customize->add_setting(\'themename_theme_options[upload_test]\', array(
\'default\' => \'arse\',
\'capability\' => \'edit_theme_options\',
\'type\' => \'option\',
));
$wp_customize->add_control( new WP_Customize_Upload_Control($wp_customize, \'upload_test\', array(
\'label\' => __(\'Upload Test\', \'themename\'),
\'section\' => \'themename_color_scheme\',
\'settings\' => \'themename_theme_options[upload_test]\',
)));
}
add_action(\'customize_register\', \'themename_customize_register\');
参考链接了解您的知识
Click