Use admin_body_class
both with global post_id and get_current_screen
function:
add_filter('admin_body_class', 'wpse_320244_admin_body_class');
function wpse_320244_admin_body_class($classes) {
global $post;
// get_current_screen() returns object with current admin screen
// @link https://codex.wordpress.org/Function_Reference/get_current_screen
$current_screen = get_current_screen();
if($current_screen->base === "post" && absint($post->ID) === 8) {
$classes .= ' home-admin-area';
}
return $classes;
}
You can also use $pagenow variable. It seems that this way would be preferable, because get_current_screen()
maybe undefined in some cases:
add_filter('admin_body_class', 'wpse_320244_admin_body_class');
function wpse_320244_admin_body_class($classes) {
global $post, $pagenow;
// $pagenow contains current admin-side php-file
// absint converts type to int, so we can use strict comparison
if($pagenow === 'post.php' && absint($post->ID) === 8) {
$classes .= ' home-admin-area';
}
return $classes;
}