PHP
<?php
function add_custom_post_type_body_class($classes) {
// Check if we're in the block editor
if (is_admin() && function_exists('get_current_screen')) {
$screen = get_current_screen();
if ($screen && $screen->post_type) {
// Add the custom post type class
$classes .= ' post-type-' . sanitize_html_class($screen->post_type);
}
}
return $classes;
}
add_filter('admin_body_class', 'add_custom_post_type_body_class');