admin管理员组

文章数量:1287893

i use woocommerce and woocommerce 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 !!! :)

i use woocommerce and woocommerce Product Vendors (https://woocommerce/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 !!! :)

Share Improve this question edited Oct 11, 2021 at 18:04 Calachuka asked Oct 11, 2021 at 17:52 CalachukaCalachuka 53 bronze badges 2
  • here is my corrected code is it better? because still does not work? here is what my functions.php file contains there may be an error? thank you ! :) <?php /* activation theme */ function wpm_enqueue_styles(){ wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' ); } add_action( 'wp_enqueue_scripts', 'wpm_enqueue_styles' ); function wp245372_admin_enqueue_scripts() { wp_enqueue_style( 'my-admin-css', get_template_directory_uri() . '/my-admin.css' ); } add_action( 'admin_enqueue_scripts', 'wp245372_admin_enqueue_scripts' ); – Calachuka Commented Oct 11, 2021 at 19:37
  • I converted your answer into a comment, this isn't a discussion forum and you had not posted a reply, you had posted the solution to your question. People might avoid your question thinking you had found the answer already. If you have updates use the Edit link underneath the tags to modify your question to add more information or updates – Tom J Nowell Commented Oct 12, 2021 at 9:46
Add a comment  | 

1 Answer 1

Reset to default 1

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.

本文标签: hide elements of admin with css file