Replies: 1 comment
-
Update: Thanks to @MadtownLems for helping to figure out that you can do this1, but:
If you manually target You can also add classes to the body using the What worked for me, as of WP 6.1: .editor-styles-wrapper {
color: black;
background-color: white;
}
body.post-type-page .editor-styles-wrapper {
color: white;
background-color: black;
} function add_editor_theme_stylesheeet()
{
if (is_admin()) {
wp_enqueue_style("editor-theme", get_stylesheet_directory_uri() . "/dist/css/editor-theme.css");
}
}
add_action("enqueue_block_assets", "add_editor_theme_stylesheeet"); This feels a bit hacky, so I would still like to know if there is a more recommended way to accomplish this. Footnotes
|
Beta Was this translation helpful? Give feedback.
-
I’m working on a custom non-FSE theme where posts have a light background, pages have a dark background, and there is a custom field to invert these defaults on a case-by-case basis. I want the block editor to at least roughly reflect what happens on the front end of the site, but I can’t figure out how to make it aware of this.
I’ve tried the following CSS, but whatever converts
body
to.editor-styles-wrapper
is unaware of the concept of the body tag having classes.I found #28233, which adds
is-dark-theme
to the body element, so I also tried addingis-dark-theme
to the body myself via theadmin_body_class
filter, which that seems to be disallowed? It just doesn’t show up.Is there a supported way to manually tell the editor what theme it should load based on the post type and/or a custom field?
Beta Was this translation helpful? Give feedback.
All reactions