猿问

试图在子主题中覆盖/附加来自父主题的 editor-style.css

我正在使用旧的 21 进行简单的工作,并使用孩子覆盖样式。


问题是,当我在子主题文件夹中添加 editor-child.css 时,编辑器样式不会被覆盖。在子主题functions.php(包装在after_setup_theme 中)中添加add_editor_style 似乎不起作用。我不能加载多个编辑器样式或者这里有什么问题?我不知道如何在古腾堡覆盖这个丑陋的 21 编辑器 css。禁用它甚至可能更好,但即使使用 remove_editor_style 也不起作用。而且我无法使用 google 或 stackoverflow 找到有关该主题的任何内容。


<?php

// In the child theme functions.php. I simply want to use the style.css by the child theme as an extra editor style

function wysiwyg_styles() {

    add_editor_style( get_stylesheet_uri() );

}

add_action( 'after_setup_theme', 'wysiwyg_styles');

?>

管理员中没有加载 css(删除 chache AND cookie 后)


GCT1015
浏览 152回答 2
2回答

胡说叔叔

发生的情况是您使用了错误的动作钩子……您应该使用admin_enqueue_scripts钩子。尝试这样做..并检查它是否适合您:add_action('admin_enqueue_scripts', function () {&nbsp; wp_enqueue_style('admin-styles', get_stylesheet_directory_uri().'/pathToYour.css');});// If the above does not work change get_stylesheet_directory_uri() for get_template_directory_uri()希望这可以帮助,祝你好运。
随时随地看视频慕课网APP
我要回答