Radio buttons Output in Theme Customizer
-
My theme has two color schemes (i.e. two stylesheets – light.css and dark.css) which I would like my multisite users to select via the theme customizer.
I am not able to output the value to my header.php. The code I used to do so is:
<?php if ( get_theme_mod( 'garnish_color_scheme' ) ) { ?> <link rel="stylesheet" href="<?php echo get_template_directory_uri(); ?>/css/<?php echo get_theme_mod( 'garnish_color_scheme' ); ?>" type="text/css" media="screen" /> <?php } else { ?> <link rel="stylesheet" href="<?php echo get_template_directory_uri(); ?>/css/light.css" type="text/css" media="screen" /> <?php } ?>
The code I am using to add the section, setting and control to the customizer is :
/*---------------------------------------------------------------*/ /* Theme Customizer - Color Scheme /*----------------------------------------------------------------*/ $wp_customize->add_section('garnish_color_scheme', array( 'title' => __('Color Scheme', 'garnish'), 'priority' => 120, )); $wp_customize->add_setting('garnish_color_scheme', array( 'default' => 'value1', 'capability' => 'edit_theme_options', 'type' => 'option', )); $wp_customize->add_control('garnish_color_scheme', array( 'section' => 'garnish_color_scheme', 'settings' => 'garnish_color_scheme', 'type' => 'radio', 'choices' => array( 'value1' => 'light.css', 'value2' => 'dark.css', ), ));
Any help would be greatly appreciated. Thanks in advance.
- The topic ‘Radio buttons Output in Theme Customizer’ is closed to new replies.