Add term of current custom post type to admin body class using admin_body_class
I think you’re missing get_current_screen(). add_filter( ‘admin_body_class’, ‘rw_admin_body_class’ ); function rw_admin_body_class( $classes ) { $screen = get_current_screen(); if ( ‘post’ != $screen->base ) { return $classes; } global $post; $terms = wp_get_post_terms( $post->ID, ‘product_cat’, array( ‘fields’ => ‘all’ ) ); $terms = wp_list_pluck( $terms, ‘slug’ ); foreach ( $terms as $term ) { $classes .= … Read more