Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

3 Answers 3

up vote 3 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

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

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

 * Add a class or many to the body in the dashboard
function 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', '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

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.