您需要向其添加控件。
function mytheme_customize_register( $wp_customize ) {
$wp_customize->add_section( \'mytheme_options\',
array(
\'title\' => __( \'MyTheme Options\', \'ppr\' ),
\'priority\' => 35,
\'description\' => __(\'Allows you to customize some example settings for MyTheme.\', \'ppr\'),
)
);
$wp_customize->add_setting( \'link_textcolor\', array(
\'default\' => get_option( \'your_theme_page_option_value\' ), THIS IS THE OPTION NAME YOU CREATED WITH YOUR OPTIONS PAGE CODE
\'type\' => \'option\', // FOR OPTIONS USE OPTION
\'capability\' => \'edit_theme_options\',
\'transport\' => \'refresh\', // WILL REFRESH INSTEAD OF JS. YOU HAVE TO WRITE JS TO MAKE UPDATE INSTANT... ITS A PAIN IN THE ASS http://codex.wordpress.org/Plugin_API/Action_Reference/customize_preview_init
) );
// THIS IS WHAT YOU WERE MISSING
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, \'link_color\', array(
\'label\' => __( \'Link Text Color\', \'ppr\' ),
\'section\' => \'mytheme_options\', // ID OF SECTION ABOVE
\'settings\' => \'link_textcolor\', // ID OF SETTINGS ABOVE
) ) );
}
add_action( \'customize_register\', \'mytheme_customize_register\' );
Alex请确保您在模板中包含选项,否则您将看不到任何更改。例如,如果您想使用所有模板中的选项,请确保您实际将该选项放在标题或所有需要更改的文件中。
因此,对于上面的代码,我将使用类似的内容,并将其放在标题中。php,甚至只是在使用wp_head
如果是针对样式,请执行操作。
function mytheme_customizer_styles() {
$link_text_color = get_option(\'your_theme_page_option_value\'); // THIS IS THE OPTION VALUE THAT YOU CREATED WITH SETTINGS API AND YOUR CUSTOM OPTIONS PAGE AND IS ALSO THE NAME OF THE OPTIONS DEFINED IN THE `add_setting` field above.
?>
<style type="text/css" id="mytheme-customizer-admin-header-css">
.link-text-color { color: <?php echo $link_text_color; ?>; }
</style>
<?php
}
add_action( \'wp_head\', \'mytheme_customizer_styles\', 9999); // JUST MAKE SURE THE PRIORITY IS LATE ENOUGH SO ITS NOT OVERRIDEEN