Custom editor color palette colors are not appearing in the editor

Below is the function to add my custom colors, the 'disable-custom-colors' is working properly, but the custom colors that I'm trying to add are not appearing in the editor. I have also tried clearing my cache and the issue persists.

function add_custom_gutenberg_color_palette() {
    add_theme_support( 'disable-custom-colors' );

    add_theme_support(
        'editor-color-palette',
        array(
            array(
                'name'  = esc_html__('Red', 'twentytwentyone-child'),
                'slug'  = 'red',
                'color' = '#E4D1D1',
            ),
            array(
                'name'  = esc_html__('Orange', 'twentytwentyone-child'),
                'slug'  = 'orange',
                'color' = '#E4DAD1',
            )
        )
    );
}
add_action( 'after_setup_theme', 'add_custom_gutenberg_color_palette' );

Thank you for the help!

Topic block-editor color-picker functions Wordpress

Category Web


I noticed that you're using a child theme of Twenty Twenty-One, which also registers custom editor color palette using the same hook and priority (i.e. 10), so try using 11 or greater as the action's priority:

add_action( 'after_setup_theme', 'add_custom_gutenberg_color_palette', 11 );

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.