Offering different color schemes using customizer
-
So I’ve got my customizer all set up thanks to Otto’s tutorial, and I have the following:
function colorpalette_theme_customizer( $wp_customize ) { $wp_customize->add_section( 'colorpalette_color_scheme_settings', array( 'title' => __( 'Color Scheme', 'colorpalette' ), 'priority' => 30, 'description' => 'Select your color scheme', ) ); $wp_customize->add_setting( 'colorpalette_color_scheme', array( 'default' => 'blue', ) ); $wp_customize->add_control( 'colorpalette_color_scheme', array( 'label' => 'Choose your color scheme', 'section' => 'colorpalette_color_scheme_settings', 'default' => 'blue', 'type' => 'radio', 'choices' => array( 'Choice 1' => 'blue', 'Choice 2' => 'red', 'Choice 3' => 'green', 'Choice 3' => 'gray', ), ) ); } add_action('customize_register', 'colorpalette_theme_customizer');
This works beautifully, but now, I want to do display a different stylesheet depending on which one they choose and this isn’t quite right:
function colorpalette_add_customizer_css() { ?> <link rel="stylesheet" href="<?php echo get_template_directory_uri();?>css/<?php echo get_theme_mod( 'colorpalette_color_scheme' ); ?>.css" type="text/css" media="screen"> <?php } add_action( 'wp_head', 'colorpalette_add_customizer_css' );
This results in the words Choice 1 or Choice 2 being displayed in the link. I’ve never liked radio buttons, but I’m sure I’m missing something simple.
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Offering different color schemes using customizer’ is closed to new replies.