我在这里做错了为什么现场css无效。
我从这里参考https://codex.wordpress.org/Theme_Customization_API,但它对我不起作用
//adding nav color controlller
$wp_customize->add_section('nav_color',array(
'title' => __('Style Navigation','dgthemecustomizer'),
'panel' => 'DG_COLOR_STYLING',
'prority' => '10'
));
$wp_customize->add_setting('nav_color',array(
'default' => '#FFFFFF',
'transport' => 'refresh'
));
$wp_customize->add_control(
new WP_Customize_Color_Control($wp_customize,'nav_color',array(
'label' => __( 'Navigation Background', 'DG_theme_customizer' ),
'section' => 'nav_color',
'settings' => 'nav_color',
'context' => 'Navigation Background'
))
);
//function for making custom style work
function custom_color_scheme(){
?>
<style type="text/css">
header{
background: #<?php echo get_theme_mod('nav_color'); ?>;
}
</style>
<?php }
add_action('wp_head', 'custom_color_scheme');
?>
答案 0 :(得分:0)
使用wp-color-picker-alpha.min.js
从github下载文件并通过wp_enque使用它。
https://github.com/23r9i0/wp-color-picker-alpha/blob/master/src/wp-color-picker-alpha.js