Wordpress - body_class hook for admin pages

Admin pages don't use the body_class filter, use the admin_body_class filter to add classes to admin body tag instead.

Note that $classes in that case is a string, not an array.


Mamaduka answer pointed me to the right direction, here is the code for adding classes to the body in the dashboard.

The callback function should return a valid value for the HTML class attribute, that is space separated class names, also, don't forget to prepend (or append) any existing classes, you should understand by reading the code.

add_filter( 'admin_body_class', 'my_admin_body_class' );

/**
 * Adds one or more classes to the body tag in the dashboard.
 *
 * @link https://wordpress.stackexchange.com/a/154951/17187
 * @param  String $classes Current body classes.
 * @return String          Altered body classes.
 */
function my_admin_body_class( $classes ) {
    return "$classes my_class";
    // Or: return "$classes my_class_1 my_class_2 my_class_3";
}