I need to switch scheme color of my WordPress theme trough Redux option panel.

My plan is switch the CSS file trough get_template_directory_uri() | Function.

The scenario is:

  1. Create 2 scheme color: dark and light with dark.css and libght.css.

  2. Control from redux panel with this code:

    Redux::setSection( $opt_name, array(
     'title'  => __( 'Color Scheme', 'javapaper' ),
     'id'     => 'test_scheme',
     'icon'   => 'el el-list',
     'fields' => array(
             'id'       => 'color_scheme',
             'type'     => 'image_select',
             'title'    => __( 'SELECT Color Scheme', 'javapaper' ),
             'subtitle' => __( '2 scheme Available', 'javapaper' ),              
             'options'  => array(
                 'dark' => array(
                     'title' => 'dark',
                     'alt' => 'dark',
                     'img' => get_stylesheet_directory_uri() . '/images/header-styledefault.png'
                 'light' => array(
                     'title' => 'light',                 
                     'alt' => 'light',
                     'img' => get_stylesheet_directory_uri() . '/images/header-style2.png'
             'default'  => 'dark'
      ) );
  3. Call the code from Redux panel into get_template_directory_uri() | Function like this:

     wp_enqueue_style( 'javapaper-lightbox-style', get_template_directory_uri() . '/css/$redux_demo["color_scheme"]' );  

But Unfortunately It did not work. I am newbie on php. Please help.

  • You should direct this question to Redux's official support channels
    – bosco
    Apr 25 at 16:37

1 Answer 1


If you are sure that $redux_demo["color_scheme"] is getting the corresponding value, so your code should be:

global $redux_demo;
wp_enqueue_style( 'javapaper-lightbox-style', get_template_directory_uri() . "/css/{$redux_demo['color_scheme']}.css" );

Assuming that you have files in this structure css/dark.css and css/light.css.

  • Unfortunately I got this warning :Notice: Undefined variable: redux_demo in F:\xamppupdate\wp\apps\wordpress\htdocs\wp-content\themes\javapaper\functions.php on line 72 Notice: Trying to access array offset on value of type null in F:\xamppupdate\wp\apps\wordpress\htdocs\wp-content\themes\javapaper\functions.php on line 72
    – Chl Lila
    Apr 17 at 22:37
  • The HTL output: <link rel='stylesheet' id='javapaper-lightbox-style-css' href='…' type='text/css' media='all' /> I need to insert the text as the name of the css, in my case dark.css and light.css.
    – Chl Lila
    Apr 17 at 22:40
  • May be you have to add the global $redux_demo;. Please check the edit
    – Makiomar
    Apr 17 at 22:42
  • It's coresponding to text "dark" and "light", the output I need "dark.css" or "light.css"
    – Chl Lila
    Apr 17 at 22:42
  • Yes and that is the main problem that you are trying to access a value stored in $redux_demo which is not defined. So while redux stores options inside the global $redux_demo; you should add it before the line you want to use within or at you function beginning.
    – Makiomar
    Apr 17 at 22:46

Not the answer you're looking for? Browse other questions tagged or ask your own question.