Home / Override Block Editor Palette Colors
Duplicate Snippet

Embed Snippet on Your Site

Override Block Editor Palette Colors

Use this snippet to control the pre-defined colors in the Block Editor.

100+
Code Preview
php
<?php
add_filter( 'wp_theme_json_data_theme', function ( $theme_json ) {
	$new_data = array(
		'settings' => array(
			'color' => array(
				'palette' => array(
					// Replace with your desired colors.
					array(
						'slug'  => 'white',
						'color' => '#ffffff',
						'name'  => 'White',
					),
					array(
						'slug'  => 'black',
						'color' => '#000000',
						'name'  => 'Black',
					),
					array(
						'slug'  => 'red',
						'color' => '#ff0000',
						'name'  => 'Red',
					),
					array(
						'slug'  => 'green',
						'color' => '#00ff00',
						'name'  => 'Green',
					),
					array(
						'slug'  => 'blue',
						'color' => '#0000ff',
						'name'  => 'Blue',
					),
				),
			),
		),
	);
	return $theme_json->update_with( $new_data );
} );

Comments

Add a Comment