hide elements of admin with css file

i use woocommerce and woocommerce Product Vendors (https://woocommerce.com/products/product-vendors/) i want hide elements of admin with css file my-admin.css I put css file my-admin.css at the root of my child theme wordpress and use this code in functions.php. This does not work?!?

function admin_css() {
    $admin_handle = 'admin_css';
    $admin_stylesheet = get_template_directory_uri() . 'my-admin.css';

    wp_enqueue_style($admin_handle, $admin_stylesheet);
}
add_action('admin_print_styles', 'admin_css', 11);

is this an obselete method? because: when i use this other method in functions.php, it's ok it works add_action('admin_head', 'my_custom_fonts');

function my_custom_fonts() {
  echo 'style
    body, td, textarea, input, select {
      font-family: Lucida Grande;
      font-size: 12px;
    } 
  /style';
}

What do you think ? thanks !!! :)

Topic admin-css admin Wordpress

Category Web


It's always better to encapsulate your styles in a separate file, so your first example is closer. That said, the documentation for admin_print_styles says quite clearly:

admin_print_styles should not be used to enqueue styles or scripts on the admin pages. Use admin_enqueue_scripts instead.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.