skip to Main Content

WordPress Code Snippets


Add a Custom Color Palette to the Block Editor

Create a custom color palette for the block editor.

add_action('init', 'codebykp_add_custom_color_palette');
function codebykp_add_custom_color_palette() {
    add_theme_support('editor-color-palette', array(
        array(
            'name' => __('Strong Magenta', 'themeLangDomain'),
            'slug' => 'strong-magenta',
            'color' => '#A500B5',
        ),
        array(
            'name' => __('Light Gray', 'themeLangDomain'),
            'slug' => 'light-gray',
            'color' => '#D7D7D7',
        ),
        // Add more colors as needed
    ));
}


I’m a WordPress developer with 10+ years of experience in WooCommerce and custom plugins. I combine technical expertise with design flair to help you create standout, user-friendly websites. Let’s transform your digital presence!

Best WordPress Hosting
Back To Top
Search