Roots Discourse

Color Scheme - Light or dark - is not running

I wanted an option of choosing themes i.e. light or dark

I followed this instructions here

But When I choose the option of light or dark, nothing changes. the color scheme remains the same.

Any idea anyone as to why?


Please post your code and a more detailed description of how you replicate the problem and how it manifests.


So i’ve added scss files in the config.json file

  "entry": {
    "main": [
    "light": [
    "dark": [
    "customizer": [
  "publicPath": "/wp-content/themes/ken",
  "devUrl": "",
  "proxyUrl": "http://localhost:3000",
  "cacheBusting": "[name]_[hash:8]",
  "watch": [

Here’s the standalone scss files




namespace App;

add_action( 'customize_register', function() {

  global $wp_customize;

     // Theme variation setting

     		class Select_Control extends \WP_Customize_Control {
     			public $type = 'select';

     			public function render_content() {
            $themes = array(
              'light' => 'Light',
              'dark' => 'Dark',
     				<span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span>
     				<select <?php $this->link(); ?>>
              <?php foreach($themes as $theme => $name) { ?>
                <option value="<?=$theme?>" <?php if($this->value() == $theme) echo 'selected="selected"'; ?>><?=$name?></option>
              <?php } ?>
     			} //render_content()
     		} //Select_Control()

     		$wp_customize->add_section('theme_colors', array('title'=>'Sub Theme'));

     		$wp_customize->add_setting('subtheme_setting', array('default'=>'light'));

     		$wp_customize->add_control( new Select_Control($wp_customize, 'subtheme_setting', array(
     			'label' => 'Color scheme',
     			'section' => 'theme_colors',
     			'setting' => 'subtheme_setting'
     		) ) );

Added it into array in functions.php

enqueue css file

add_action('wp_enqueue_scripts', function () {
    wp_enqueue_style('sage/main.css', asset_path('styles/' . get_theme_mod( 'subtheme_setting' )  . '.css'), false, null);

    wp_enqueue_script('sage/main.js', asset_path('scripts/main.js'), ['jquery'], null, true);
    wp_localize_script( 'sage/main.js', 'ajax_object', array( 'ajax_url' => admin_url( 'admin-ajax.php' ) ) );
}, 100);

The problem that I have is that when selected light or dark theme it doesn’t change anything

the css link (below) can be seen in the sourecode but it doesnt have anything in it.

<link rel='stylesheet' id='sage/main.css-css' href='' type='text/css' media='all' />

Did you do a yarn build to create the new stylesheets?


haha such a silly of me.

thank you! worked!