Skip to content

Instantly share code, notes, and snippets.

@jayseventwo
Created May 6, 2015 03:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jayseventwo/a4239cf3f90d06375a77 to your computer and use it in GitHub Desktop.
Save jayseventwo/a4239cf3f90d06375a77 to your computer and use it in GitHub Desktop.
add_action( 'customize_register', 'themename_customize_register' );
function themename_customize_register($wp_customize) {
// add new section
$wp_customize->add_section( 'bwpy_theme_colors', array(
'title' => __( 'Theme Colors', 'bwpy' ),
'priority' => 100,
) );
// add color picker setting
$wp_customize->add_setting( 'link_color', array(
'default' => '#ff0000'
) );
// add color picker control
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'link_color', array(
'label' => 'Link Color',
'section' => 'bwpy_theme_colors',
'settings' => 'link_color',
) ) );
function bwpy_customizer_head_styles() {
$link_color = get_theme_mod( 'link_color' );
if ( $link_color != '#ffffff' ) : ?>
<style type="text/css">
.header_bg_color {
background-color: <?php echo $link_color; ?>;
}
</style>
<?php endif; }
add_action( 'wp_head', 'bwpy_customizer_head_styles' );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment