admin管理员组

文章数量:1203400

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!

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!

Share Improve this question asked Mar 30, 2022 at 15:02 BeccaNBeccaN 171 silver badge6 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 2

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 );

本文标签: functionsCustom editor color palette colors are not appearing in the editor