WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

The body_class hook seem only to work with non-admin pages. When I do

add_filter('body_class', 'add_body_classes');
function add_body_classes($classes) {
        $classes[] = 'myclass';
        return $classes;

Is there another hook i should be using if i want to add a class to the body of an admin page?

share|improve this question
up vote 7 down vote accepted

Admin doesn't use body_class() template tag, use admin_body_class filter too add classes to admin body tag.

share|improve this answer
It's worth noting that the $classes parameter in the method for the admin_body_class filter is a string and not an array developer.wordpress.org/reference/hooks/admin_body_class – Roman Epicnerd Sharf May 25 at 16:30

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

 * Adds one or more classes to the body tag in the dashboard.
 * @param  String $classes Current body classes.
 * @return String          Altered body classes.
function se_154951_add_admin_body_class( $classes ) {
    return "$classes my_class";
    // Or:
    // return "$classes my_class_1 my_class_2 my_class_3";

add_filter( 'admin_body_class', 'se_154951_add_admin_body_class' );

The hook callback function should return a valid value for the 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.

share|improve this answer
This should probably be the selected answer. Asker's original implementation returns an array, but the hook accepts a space-separated string: https://developer.wordpress.org/reference/hooks/admin_body_class/. Selected answer is therefore misleading, as it only partially answers the question and provides no reference. – smspaulb Oct 2 '15 at 19:30

one of the hooks i use for editing WP admin/Dashboard admin_head

    function remove_screen_options(){ 

    $hideCSS = '<style>#screen-meta-links { display: none; }</style>';


Will put the css in your admin part

And by using class .wp-admin you could style the body part of admin.

Good luck

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.