WordPress颜色选择器无法正常工作

时间:2016-11-15 11:43:19

标签: wordpress colors themes picker

颜色选择器仍然是主题自定义选项,但是当我改变链接和按钮的颜色时,颜色不会改变按钮和链接。请帮助感谢您的宝贵答案。

//Customize Appearance Options

function myTheme_customize_register( $wp_customize ) {

//设置链接颜色

    $wp_customize->add_setting('mtm_link_color', array(
        'default' => '#006ec3',
        'transport' => 'refresh',
    ));

//设置按钮颜色

    $wp_customize->add_setting('mtm_btn_color', array(
        'default' => '#006ec3',
        'transport' => 'refresh',
    ));

//标准颜色的部分

    $wp_customize->add_section('mtm_standard_colors', array(
        'title' => __('Standard Colors', 'MyTheme'),
        'priority' => 30,
    ));

//为链接颜色选择器添加控件

    $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize,'mtm_link_color_control', array(
        'label' => __('Link Color', 'MyTheme'),
        'section' => 'mtm_standard_colors',
        'settings' => 'mtm_link_color',

    ) ) );

//添加按钮颜色选择器的控件

    $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize,'mtm_btn_color_control', array(
     'label' => __('Button Color', 'MyTheme'),
     'section' => 'mtm_standard_colors',
     'settings' => 'mtm_btn_color',

 ) ) );

}

add_action('customize_register', 'myTheme_customize_register');


//Output Customize CSS

function myTheme_customize_css() { ?>
    <style type="text/css">

             a:link,
       a:visited
             {
                 color:<?php echo get_theme_mod('mtm_link_color'); ?> ;
             }

             .site-header nav ul li.current-menu-item a:link,
             .site-header nav ul li.current-menu-item a:visited{
                 background-color: <?php echo get_theme_mod('mtm_link_color'); ?> ;
             }

       div.search #searchsubmit{
                  background-color: <?php echo get_theme_mod('mtm_btn_color'); ?> ;
             }

    </style>
<?php }
add_action('wp_haed', 'myTheme_customize_css');

0 个答案:

没有答案