我正在创建一个主题,我已经开始在主题定制器上做一些工作。我将在主题函数中完成所有操作,但我首先要解决一个问题:
我添加了一个排版部分,目前只有一些颜色选择器可以更改段落文本和链接的颜色。然而,它不起作用。没有错误,部分显示有选项,但更改颜色时没有任何更改。这是我的代码,如果有人能帮我,我会很激动:)
/* Theme Customizer Code */
function dsgn_customizer_register($wp_customize) {
$wp_customize->add_section(\'dsgn_typograhy\', array(
\'title\' => __(\'Typography\', \'dsgn\'),
\'description\' => (\'Modify the theme typography\')
));
$wp_customize->add_setting(\'content_color\', array(
\'default\' => \'#544e4e\',
));
$wp_customize->add_setting(\'link_color\', array(
\'default\' => \'#BF5050\',
));
$wp_customize->add_control( new WP_customize_color_control($wp_customize, \'content_color\', array(
\'label\' => __(\'Edit Content Text Color\', \'dsgn\'),
\'section\' => \'dsgn_typograhy\',
\'settings\' => \'content_color\'
) ));
$wp_customize->add_control( new WP_customize_color_control($wp_customize, \'link_color\', array(
\'label\' => __(\'Edit Link Text Color\', \'dsgn\'),
\'section\' => \'dsgn_typograhy\',
\'settings\' => \'link_color\'
) ));
}
function dsgn_css_customizer() {
?>
<style type="text/css">
a {
color: <?php echo get_theme_mod(\'link_color\'); ?>;
}
.entry-content p {
color: <?php echo get_theme_mod(\'content_color\'); ?>;
}
</style>
<?php
}
add_action(\'wp-head\', \'dsgn_css_customizer\');
add_action(\'customize_register\', \'dsgn_customizer_register\');
NOTE: 我尝试为身体背景色添加另一个控件,效果非常好。。。实际上,我已经使用以下代码支持背景色:
// Add theme support for Custom Background
$background_args = array(
\'default-color\' => \'e9e9e9\',
\'default-image\' => \'\',
\'wp-head-callback\' => \'_custom_background_cb\',
\'admin-head-callback\' => \'\',
\'admin-preview-callback\' => \'\',
);
add_theme_support( \'custom-background\', $background_args );
当我删除这些代码时,这个选项就不起作用了,所以我猜我可能还需要添加一些对排版更改的支持。。?