• Resolved b…b

    (@bb-4)


    I am working on a new website using Vega (great theme).

    I have created a child theme and am looking for help with the colors.

    Below is a screenshot comparing two code snippets for vega-child theme functions.php.

    https://www.currentinspiration.com/temp/Vega-child_functionsBluevsfunctions.JPG

    The code on the left forces a blue color no matter what color is chosen in the customizer. The code on the right allows the color choice from the customizer to work correctly.

    Can you help me understand why?

    Also, is it possible to reference my own /vega-child/color-schemes from functions.php?

    • This topic was modified 7 years, 6 months ago by b...b.
Viewing 5 replies - 1 through 5 (of 5 total)
  • Theme Author lyrathemes

    (@lyrathemes)

    The vega_get_option function in your child theme should be:

    function vega_wp_get_option($key){
        global $vega_wp_defaults;
        
        $parent_theme = get_template_directory();
        $parent_theme_slug = basename($parent_theme);
        $parent_theme_mods = get_option( "theme_mods_{$parent_theme_slug}");
        
        $child_value = get_theme_mod($key);
        if(!empty($child_value)){
            $value = $child_value;
        }
        else if (!empty($parent_theme_mods) && isset($parent_theme_mods[$key])) {
            $value = $parent_theme_mods[$key];
        } else if (array_key_exists($key, $vega_wp_defaults)) 
            $value = get_theme_mod($key, $vega_wp_defaults[$key]); 
        
        return $value;
    }
    Thread Starter b…b

    (@bb-4)

    Does not answer my question.

    Why does code on the left side use the blue color scheme?

    https://www.currentinspiration.com/temp/Vega-child_functionsBluevsfunctions.JPG

    Theme Author lyrathemes

    (@lyrathemes)

    The code on the left uses the parent theme option if it has been set. So if you saved the options once with the parent theme and then set up the child theme, the parent theme options will remain in effect.

    Thread Starter b…b

    (@bb-4)

    Thanks.

    Can I use a child theme: vega-child/color-schemes/somefile.css ?

    Theme Author lyrathemes

    (@lyrathemes)

    You sure can, just be sure to enqueue it properly in the child theme functions.php file.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Child Theme – Colors’ is closed to new replies.