Action Hook since 2.8.0

admin_enqueue_scripts

The correct hook to enqueue admin-only assets

Description

admin_enqueue_scripts is the admin equivalent of wp_enqueue_scripts — always check $hook_suffix so you don't load your CSS/JS on every admin screen.

When it runs

On every wp-admin page load, before the admin page markup renders.

Signature

do_action( 'admin_enqueue_scripts', string $hook_suffix );

Parameters

  • $hook_suffix string — The current admin page identifier, e.g. post.php or a plugin's own page hook.

Examples

Basic

add_action( 'admin_enqueue_scripts', function( $hook_suffix ) {
    if ( 'post.php' !== $hook_suffix ) {
        return;
    }
    wp_enqueue_script( 'my-admin-js', plugins_url( 'admin.js', __FILE__ ), [ 'jquery' ], '1.0', true );
} );

Load a script only on the post edit screen.

Common Use Cases

  • Enqueue admin CSS/JS scoped to one screen
  • Load a color picker or media uploader script
  • Pass data to admin JS via wp_localize_script

Common mistakes

  • Enqueueing admin assets without checking $hook_suffix — they load on every admin page and slow the dashboard down

Related hooks

FAQ

How do I find the right $hook_suffix value?

Add error_log($hook_suffix) inside the callback and check your PHP error log while on the target screen, or use get_current_screen()->id.

Source: wp-admin/admin-header.php

Group wizard

One session: this hook, then each related_hooks entry. Walk it and tell us what to change.

admin_enqueue_scripts → wp_enqueue_scripts

functions.php — admin_enqueue_scripts
functions.php
PHP admin_enqueue_scripts · Hook 1 of 2 · Step 1 of 6

Practice the admin_enqueue_scripts WordPress action hook in our interactive sandbox — a VS Code-style editor with a step-by-step admin_enqueue_scripts tutorial, add_action exercises, and instant feedback. No local WordPress install required.