I have registered a custom post type using register_post_type('myposttype', ...)
. On published posts, there is a custom class that gets applied to the whole body of the page, single-myposttype
. I apply css rules using this body class to make the post appear differently from non-custom post types posts.
Now that the Gutenberg editor is such a key part of Wordpress, I would like to be able to add a custom body class to the editor when working on these custom post types, so that the same style rules that apply to the published post are applied during editing.
I have seen some answered questions (e.g. this one) which use javascript, however if I understand correctly they would apply to the editor for all posts and pages, not just custom post types.
<body class=""..." >
of the edit page? If so, I wonder if you could use thebody.post-php.post-type-myposttype.block-editor-page
selector?