在WordPress子主题中自定义编辑器样式

昨天调了一下主题的字体,但是在后台编辑器中的字体还是系统默认字体,不太好看,强迫症的我打算把后台编辑器的字体也改一下。

在子主题的 functions.php 文件中,添加下面的代码

function xy_block_editor_styles() {
	wp_enqueue_style( 'xy-editor-styles', get_theme_file_uri() .'/css/style-editor.css', false, '1.0', 'all' );
}

add_action( 'enqueue_block_editor_assets', 'xy_block_editor_styles', 1, 1 );

get_theme_file_uri() 为子主题的目录,后面加上你为编辑器准备的样式文件即可,比如我的路径为 /css/style-editor.css