1

Right now I am editing a Twenty Fifteen Child theme (Five Beers to be exact) and I'm wondering if there is a way I can add my own color scheme to the customizer and make it the default color scheme. This is the code that I've been using to add a color scheme to the list, and I sourced it from here:

  add_filter('twentyfifteen_color_schemes', 'my_custom_color_schemes');
function my_custom_color_schemes( $schemes ) {
    $schemes['maroon'] = array(
        'label'  => __( 'Maroon', 'twentyfifteen' ),
        'colors' => array(
            '#f1f1f1',
            '#C32148',
            '#ffffff',
            '#333333',
            '#333333',
            '#f7f7f7',
        ),
    );
    return $schemes;
}

anyone have any ideas?

  • So what is the problem here exactly? – user2015 Jul 8 '15 at 0:12
  • the code snippet above shows how to add a new color to the color scheme dropdown menu in the customizer. I would like to be able to add a color and make it the default color, or somehow find a way to edit the existing default color within the twentyfifteen_color_schemes array. does that help explain it a little better? – Kat Jul 8 '15 at 2:51
0

I would expect that if you add a new filter with a higher priority it gets added to the existing color schemes:

add_filter( 'twentyfifteen_color_schemes', 'wpse193782_custom_color_schemes', 99 );
function wpse193782_custom_color_schemes( $schemes ) {
    $schemes['default'] = array(
        'label'  => __( 'Colors by Kat', 'twentyfifteen' ),
        'colors' => array(
            '#f1f1f1',
            '#C32148',
            '#ffffff',
            '#333333',
            '#333333',
            '#f7f7f7',
        ),
    );
    return $schemes;
}

Edited my answer. By (re)naming the scheme ['default'] your own color scheme replaces the default color scheme.

  • Is there a way to remove the default color scheme from the array and add my own new default? Otherwise I'd like to remove the color scheme feature in the customizer all together – Kat Jul 8 '15 at 4:11
  • So I went ahead and did a bit of puzzling on a local install and found a way to replace the default color scheme. I edited my answer above to reflect the solution. – user2015 Jul 8 '15 at 4:47
  • You're welcome :) Now you only need to find a solution to make sure that not only your customised color scheme is selected, but also that those colors are used by default. For that to work properly you need to look at the twentyfifteen/inc/customizer.php file. On line 160 there is if ( ! function_exists( 'twentyfifteen_get_color_scheme' ) ), which means you can call the twentyfifteen_get_color_scheme() function from your child theme and play around with it. Same goes for line 180, the twentyfifteen_get_color_scheme_choices() function. – user2015 Jul 8 '15 at 5:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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