How can you change default color scheme in a Twenty Fifteen child theme?
-
03-10-2020 - |
Question
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?
La solution
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.
Licencié sous: CC-BY-SA avec attribution
Non affilié à wordpress.stackexchange