admin管理员组

文章数量:1122846

I am learning WordPress Plugin development. I would like to load my specific CSS file in my specific Admin Pages not in other Admin Pages.

How can I do that ?

I am learning WordPress Plugin development. I would like to load my specific CSS file in my specific Admin Pages not in other Admin Pages.

How can I do that ?

Share Improve this question asked Sep 7, 2024 at 6:00 FoysalFoysal 4451 gold badge5 silver badges15 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 2
/**
 * Enqueue a script or stylesheet in the WordPress admin on edit.php.
 *
 * @param string $hook_suffix Hook suffix for the current admin page.
 */
function wpse426722_admin_enqueue( $hook_suffix ) {
    if( 'admin_print_scripts-profile' == $hook_suffix ) {
        wp_enqueue_style( 'your-stylesheet-slug', '/path/to/your_stylesheet.css' );
    }
}

add_action( 'admin_enqueue_scripts', 'wpse426722_admin_enqueue' );

The above function has the hook suffix for when you're viewing your profile, you'll need to replace it with the hook suffix for whatever page you're targeting.

本文标签: plugin developmentLoad specific CSS file