October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk3 min

WordPress Enqueue Hooks: Four Hooks, Four Different Zones

A practical guide to WordPress asset hooks: where front-end, dashboard, login, shared block, and block-editor scripts and styles belong.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Choose a WordPress enqueue hook by where an asset should appear: use wp_enqueue_scripts for the public site, admin_enqueue_scripts for dashboard pages, login_enqueue_scripts for login screens, and enqueue_block_assets for assets shared by blocks on the front end and in the editor. For the block editor interface alone, use the separate enqueue_block_editor_assets hook.

Which WordPress enqueue hook should you use?

Hook Where the asset belongs Typical audience Scope
wp_enqueue_scripts Public front end Site visitors Front-end scripts and styles
admin_enqueue_scripts Administration screens Site administrators and other dashboard users Admin scripts and styles; can be narrowed to a screen using its hook suffix
login_enqueue_scripts Login and registration screens People authenticating or registering Login-area scripts and styles
enqueue_block_assets Block content on the front end and in the editor Site visitors and content editors Shared block assets
enqueue_block_editor_assets Block editor interface Content editors Editing-interface assets only

The first four hooks are the four broad destination zones. The fifth is important because its name resembles the shared block hook, but its destination is different.

As an Amazon Associate I earn from qualifying purchases.

Use the hook for the public site

Register front-end scripts and styles on wp_enqueue_scripts. Despite the word “scripts,” the action is also the correct place to enqueue styles intended for the public-facing site. WordPress Developer Resources calls it the proper hook for scripts and styles meant to appear on the front end: wp_enqueue_scripts hook reference.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The wp_enqueue_scripts() function is a wrapper for that action. It runs first in wp_head(), when conditional checks such as is_home() and is_page() are available. That makes the hook suitable for loading an asset only on relevant front-end requests, rather than across every public page. See the function reference.

Use the admin hook, then narrow it to the right screen

For dashboard-only scripts or styles, use admin_enqueue_scripts. It handles styles as well as scripts, and its callback receives the current admin page’s hook suffix. Check that value when an asset is needed on just one screen; otherwise, it may load throughout the administration area. WordPress documents the action and its suffix parameter in the admin_enqueue_scripts reference.

For example, the callback can accept the suffix and return early on screens that should not receive the asset:

add_action( 'admin_enqueue_scripts', 'my_admin_assets' );

function my_admin_assets( $hook_suffix ) {
    if ( 'toplevel_page_example' !== $hook_suffix ) {
        return;
    }

    wp_enqueue_style(
        'my-admin-style',
        plugin_dir_url( __FILE__ ) . 'admin.css'
    );
}

Replace toplevel_page_example with the suffix for the intended screen. The specific suffix depends on the page being targeted; do not assume this example value matches a plugin or site’s screen.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use the login hook for login and registration screens

Use login_enqueue_scripts for assets meant for the WordPress login area, including styles. The hook reference describes it as the proper action for items intended for the login page: login_enqueue_scripts.

This keeps authentication-screen assets separate from both public-site assets and dashboard assets. A login-page stylesheet does not belong on wp_enqueue_scripts merely because visitors can see that page, nor on admin_enqueue_scripts just because it is part of WordPress.

Choose between the two block hooks by destination

Shared block assets: enqueue_block_assets

Use enqueue_block_assets when an asset belongs to block content in both the front end and the editor. Since WordPress 6.3, assets added through this action are also enqueued for the editor iframe. The behavior and version note are in the enqueue_block_assets reference.

If a block style should be available only in the editor, the hook reference gives an is_admin() example for restricting it. This is useful when shared block styling would otherwise affect the public site but the desired asset is editor-only.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Editor interface assets: enqueue_block_editor_assets

Use enqueue_block_editor_assets for assets of the block editing interface itself, not for styling block content shared with the public site. The distinction is documented in the enqueue_block_editor_assets reference.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Keep assets out of unrelated screens

For each asset, identify its actual destination before choosing a hook. A script needed by public pages should not be attached to an admin action; a dashboard control should not load for visitors; and login-specific CSS should stay on the login path. The wp_enqueue_script() reference recommends using the matching front-end, admin, or login action and warns that enqueuing on all admin screens can cause conflicts or degrade the administration experience: wp_enqueue_script function reference.

  • Public pages: wp_enqueue_scripts.
  • Dashboard pages: admin_enqueue_scripts, narrowed by the page suffix when appropriate.
  • Login or registration: login_enqueue_scripts.
  • Block content in both editor and front end: enqueue_block_assets.
  • Block editor interface only: enqueue_block_editor_assets.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.