您可以向wordpress自定义管理页面主体类添加自定义类,如下所示
$wpdocs_admin_page = add_options_page(__(\'Wpdocs Admin Page\', \'wpdocs_textdomain\'),
__(\'Wpdocs Admin Page\', \'wpdocs_textdomain\'),
\'manage_options\', \'wpdocs_textdomain\', \'wpdocs_admin_page\');
add_filter( \'admin_body_class\', \'rw_admin_body_class\' );
function rw_admin_body_class( $classes )
{
$screen = get_current_screen();
if ( wpdocs_admin_page == $screen->id)
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 .= \' my_taxonomy-\' . $term;
}
return $classes;
}