WordPress 主题开发技巧:自定义颜色 wordpress theme develop custom colors

本主题由 隐藏人物 创建于 2016-3-2 17:36:59

A Guide to the WordPress Theme Customizer: Adding a New Setting
http://code.tutsplus.com/tutorials/a-guide-to-the-wordpress-theme-customizer-adding-a-new-setting--wp-33180

function tcx_register_theme_customizer( $wp_customize ) {

$wp_customize->add_setting(
'tcx_link_color',
array(
'default' => '#000000'
)
);

$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize,
'link_color',
array(
'label' => __( 'Link Color', 'tcx' ),
'section' => 'colors',
'settings' => 'tcx_link_color'
)
)
);

}
add_action( 'customize_register', 'tcx_register_theme_customizer' );

function tcx_customizer_css() {
?>
<style type="text/css">
a { color: <?php echo get_theme_mod( 'tcx_link_color' ); ?>; }
</style>
<?php
}
add_action( 'wp_head', 'tcx_customizer_css' );

放心注册,GeeKaa不会虚耗你半点时间,你只会发现更多乐趣。 立即注册