Checked on 15 Nov 2026 against WordPress 7.1.4 core source and a logging mu-plugin, PHP 8.5.5, Twenty Twenty-Five 1.5, no other plugins. The order below comes from those logs and from the source files that fire each hook, not from memory or an old diagram.
Every request first runs the same trunk: muplugins_loaded, plugins_loaded, setup_theme, after_setup_theme, init, wp_loaded. After wp_loaded the path splits. A front-end page parses the request, runs the main query, and picks a template. An admin screen builds the menu and fires admin_init. A REST call fires rest_api_init from inside parse_request and exits before any template. AJAX goes from wp_loaded to admin_init to your handler. Cron goes from wp_loaded straight to the due events.
Most hook bugs we are asked to fix in client plugins come down to two things: code attached to a hook that never fires on that request type, or code that runs before the thing it depends on exists. This guide gives one table per request type, what belongs on each hook, how wp_is_serving_rest_request() behaves by hook and priority, the remove_action() traps with real results, the problems people keep reporting, and the small plugin we used to log all of it. No search data existed for this page (Google had not reported any query for it yet), so the headings below follow the questions developers ask when a hook misbehaves.
What order do WordPress hooks fire in on every request?
The same order, for front end, admin, REST, AJAX and cron: the bootstrap runs inside wp-settings.php and nothing a plugin does changes it. This table is the shared trunk, with the core file or function that fires each step.
Step | What happens | Fired from |
|---|---|---|
1 | Must-use plugins load; | wp-settings.php |
2 | Core registers its own post types and taxonomies, before any regular plugin file is included | wp-settings.php |
3 | Each active plugin file is included; | wp-settings.php |
4 |
| wp-settings.php |
5 |
| wp-settings.php |
6 |
| wp-settings.php |
7 |
| wp-settings.php |
8 |
| WP::init() then wp-settings.php |
9 |
| wp-settings.php |
Two details from the logs are worth knowing before you rely on any of this.
First, core’s built-in post types and taxonomies are registered right after muplugins_loaded and before your plugin file is even included. That is why get_post_type_object( 'post' ) works early, while your own post types do not exist until you register them on init.
Second, the position of set_current_user depends on the request. On a logged-out front-end or REST request it fired after after_setup_theme, because the user is resolved by WP::init() just before init. On logged-in admin and AJAX requests it fired before after_setup_theme, because core asks for the user’s locale while it loads translations: determine_locale() calls get_user_locale() whenever is_admin() is true. So “when is the current user known” has no single answer. Do not depend on either position.
Which hook should I use to bootstrap a plugin?
Use plugins_loaded to wire up your plugin, and init to register anything WordPress keeps in a global registry. By plugins_loaded every other plugin’s file has been included, so class_exists( 'WooCommerce' ) gives a reliable answer. Pluggable functions such as wp_get_current_user() and is_user_logged_in() exist by then too. They do not exist while your main plugin file is being included, so calling them at file scope is a fatal error on some setups.
<?php
/**
* Plugin Name: Acme Events
*/
// File scope: define constants and require files only.
define( 'ACME_EVENTS_FILE', __FILE__ );
require __DIR__ . '/includes/class-acme-events.php';
// Every other plugin is loaded now. Safe to check for dependencies.
add_action( 'plugins_loaded', array( 'Acme_Events', 'boot' ) );
// Registries: post types, taxonomies, shortcodes, blocks, rewrite rules.
add_action( 'init', array( 'Acme_Events', 'register_content' ) );Checked on 15 Nov 2026. If this is your first plugin and you want the file layout around it, the WordPress plugin development tutorial walks through it from an empty folder, and the custom post types tutorial covers what to register on init.
What fires on a front-end page request, and in what order?
After wp_loaded, wp-blog-header.php calls wp(). That parses the URL, runs the main query, sends headers, and fires wp. Then template-loader.php fires template_redirect and includes the template. This is the measured order for the front page of a block theme, logged out. Hooks that fire many times (like the_post) are listed at their first firing.
# | Action | What belongs here |
|---|---|---|
1 |
| Code that must run before regular plugins, such as an early environment check. |
2 |
| Plugin bootstrap, dependency checks, loading integrations. |
3 |
| Rarely used. Fires just before the theme’s |
4 |
|
|
5 |
| Reacting to the user being resolved. Most code does not need it. |
6 |
| Post types, taxonomies, shortcodes, blocks, rewrite rules, form handlers. |
7 |
| Work that needs everything loaded but runs before the query, such as handling a POST and redirecting. |
8 |
| Custom routing based on query vars. REST requests branch off here. |
9 |
| Adjusting the parsed query flags. |
10 |
| Changing the main query (check |
11 |
| Debugging the final SQL selection. Rarely needed. |
12 |
| Custom HTTP headers (cache, security, CORS for front-end pages). |
13 |
| The main query has run. First point where |
14 |
| Redirects and access control for front-end pages. Last stop before output. |
15 |
| Last hook before the template file is included. |
16 |
| Per-loop and per-post adjustments. On a block theme these fire before |
17 |
| Meta tags and inline head output. Core runs the enqueue step at priority 1 and prints styles and scripts at 8 and 9. |
18 |
| Enqueue front-end CSS and JS. Core attaches it to |
19 |
| Printing queued assets. Do not enqueue here. |
20 |
| Output right after the opening body tag (tag managers, skip links). |
21 |
| Footer output and late scripts. |
22 |
| Printing footer scripts. Fires inside |
23 |
| Logging and cleanup after output. Core also starts the cron spawn here (see the cron section). |
Three small things sit between the rows. widgets_init, wp_sitemaps_init and wp_connectors_init all fire inside init (the Connectors registry added in WordPress 7.0 is set up at priority 15), so anything you attach to init at a lower priority number runs before them.
Why did the loop fire before the page header?
Because this is a block theme. WordPress renders the whole block template to a string first and prints wp_head afterwards, so loop_start, the_post and loop_end all fired before wp_head in our log. In a classic theme, header.php calls wp_head() before the loop, so the order flips.
That matters in two places. If you set a flag inside a block’s render callback (“this page has a gallery, load the gallery CSS”), a block theme lets you enqueue in time for the head, while a classic theme does not and the style lands in the footer. And code that assumes “wp_head has run, so the page has started” is wrong on block themes. To decide something about the page before any rendering, use wp or template_redirect, which fire before the template in both theme types.
Where should I put redirects and access checks?
On template_redirect. The main query has run, so conditional tags work, and no output has been sent, so wp_safe_redirect() still works. A redirect hooked to init has no query yet, so is_page( 'members' ) is always false there.
add_action( 'template_redirect', function () {
if ( is_page( 'members' ) && ! is_user_logged_in() ) {
wp_safe_redirect( wp_login_url( get_permalink() ) );
exit;
}
} );Checked on 15 Nov 2026. This protects the HTML page only. template_redirect never fires for /wp-json/ requests (see the REST table below), so the same content served through the REST API needs its own permission check.
What fires on a wp-admin page request?
An admin request shares the trunk up to wp_loaded. Then wp-admin/admin.php calls auth_redirect(), requires menu.php (which fires _admin_menu and admin_menu), fires admin_init, sets the current screen, and prints the page. This is the measured order for wp-admin/edit.php as an administrator.
# | Action | What belongs here |
|---|---|---|
1 |
| Plugin bootstrap, same as the front end. |
2 |
| Fires before |
3 |
| Same jobs as the front end. |
4 |
| Fires when the login check passes. Rarely hooked. |
5 |
| Internal, fired by core just before the public hook. |
6 |
|
|
7 |
|
|
8 |
| Admin bar setup. |
9 |
| First point where |
10 |
| Code for one screen. The suffix is the page hook ( |
11 |
| Only on screens that run a post query, like this list table. Not on every admin page. |
12 |
| Admin CSS and JS. Receives |
13 |
| Printing queued assets. |
14 |
| Inline output in the admin head. |
15 |
| Output at the top of the page body; adding admin bar nodes. |
16 |
| Admin notices. |
17 |
| Filter dropdowns above the posts list table. |
18 |
| Footer output, modal markup. |
19 |
| Printing footer scripts. |
20 |
| Cleanup. |
Does the admin menu hook fire before admin_init?
Yes, and it catches experienced developers. In our log admin_menu fired at position 52 of the request and admin_init at 53, because wp-admin/admin.php requires menu.php a few lines before it calls do_action( 'admin_init' ). The name suggests admin_init is the start of admin, but on a normal admin page it is not the first admin hook.
The practical bug: a plugin sets a property in admin_init (“is the license active?”) and reads it in the admin_menu callback to decide whether to show a submenu. The property is always empty when the menu is built. Compute the value inside the admin_menu callback, or compute it on plugins_loaded or init, which run before both.
How do I run code on one admin screen only?
Use load-{$page_hook}, or check the screen on current_screen. add_menu_page() and add_submenu_page() return the page hook, so you can attach to exactly your screen.
add_action( 'admin_menu', function () {
$hook = add_menu_page( 'Acme Reports', 'Acme Reports', 'manage_options', 'acme-reports', 'acme_render_reports' );
// Runs only when this screen loads, after admin_init and current_screen.
add_action( "load-{$hook}", 'acme_reports_handle_actions' );
} );
add_action( 'admin_enqueue_scripts', function ( $hook_suffix ) {
if ( 'toplevel_page_acme-reports' !== $hook_suffix ) {
return;
}
wp_enqueue_script( 'acme-reports', plugins_url( 'build/reports.js', __FILE__ ), array(), '1.0.0', true );
} );Checked on 15 Nov 2026.
What fires on a REST API request?
A REST request runs the same trunk to wp_loaded. Then parse_request fires, core’s rest_api_loaded() callback defines REST_REQUEST, builds the server (which fires rest_api_init), serves the response, and calls die(). There is no wp, no template_redirect, no wp_head and no admin_init. We requested /wp-json/wp/v2/posts logged out.
# | Action | What belongs here |
|---|---|---|
1 |
| Plugin bootstrap. |
2 |
| Theme setup. Runs on REST too. |
3 |
| User resolved from the cookie. Application Password and other auth run through filters here. |
4 |
| Post types and meta registration. |
5 |
| Everything loaded. |
6 |
| The REST branch starts here, in a callback at the default priority. |
7 |
|
|
8 |
| Fires as core registers settings for the settings endpoint. |
9 |
| Fires for the controller’s |
10 |
| Fires as posts are prepared for the response. |
11 |
| Cleanup. |
When does the REST request check become true?
Only once rest_api_loaded() has run on parse_request. wp_is_serving_rest_request() (added in WordPress 6.5) is one line: defined( 'REST_REQUEST' ) && REST_REQUEST. The constant is defined inside rest_api_loaded(), and the function’s own documentation says not to call it before parse_request. We logged the return value at each point of a real REST request on 7.1.4:
Where you call it | Returns |
|---|---|
| false, even on a REST request |
| false |
| Never runs: the request has already exited |
| true |
Route callback and | true |
So the check cannot tell you “this is a REST request” at init. If you need to skip heavy work on REST requests, put the check on rest_api_init or inside the route callback, or accept that code on init runs for REST too. The same applies to is_admin(): it is false on every REST call, including the ones the block editor makes from inside wp-admin, because it only reports whether the request is for an admin screen.
Why is my REST route returning rest_no_route?
Almost always because register_rest_route() ran on the wrong hook. It must run on rest_api_init. Registering on admin_init fails because admin_init never fires on REST requests. Registering on init can appear to work but raises a _doing_it_wrong notice. Registering inside if ( is_admin() ) fails because is_admin() is false on REST requests.
add_action( 'rest_api_init', function () {
register_rest_route( 'acme/v1', '/events', array(
'methods' => WP_REST_Server::READABLE,
'callback' => 'acme_rest_list_events',
'permission_callback' => function () {
return current_user_can( 'edit_posts' );
},
) );
} );Checked on 15 Nov 2026. The same rule covers access control: if a front-end page is gated on template_redirect, the matching REST route needs a real permission_callback, because the REST request never passes through template_redirect. For how the current user is resolved on REST calls from outside the browser, see our WordPress REST API authentication guide.
What fires on an admin-ajax.php request?
An AJAX call through admin-ajax.php runs the trunk, then admin_init, then your wp_ajax_{action} handler (logged in) or wp_ajax_nopriv_{action} handler (logged out), then exits. It does not fire admin_menu, current_screen or any template hook. We sent action=heartbeat as a logged-in administrator.
# | Action | What belongs here |
|---|---|---|
1 |
| Plugin bootstrap. |
2 |
| Fires before |
3 |
| Theme setup, registries, everything loaded. |
4 |
| Runs on every AJAX request, logged in or not. |
5 |
| Your handler: |
6 |
| Cleanup. |
Why does admin_init slow down front-end AJAX?
admin-ajax.php is an admin request. is_admin() returns true and admin_init fires, even for a logged-out visitor clicking “load more” on the front end. Any plugin that does heavy work on admin_init (update checks, building a settings array, redirecting to a welcome screen) does it on every one of those calls. A redirect there can break AJAX outright, because the response becomes an HTML redirect instead of JSON. Guard admin-only work with wp_doing_ajax():
add_action( 'admin_init', function () {
if ( wp_doing_ajax() ) {
return; // Not a screen. Skip the welcome redirect and heavy setup.
}
if ( get_option( 'acme_show_welcome' ) ) {
delete_option( 'acme_show_welcome' );
wp_safe_redirect( admin_url( 'admin.php?page=acme-welcome' ) );
exit;
}
} );Checked on 15 Nov 2026. For new front-end features a REST route is usually the better choice: it skips admin_init entirely, is easier to cache, and gives you argument validation.
What fires when WP-Cron runs?
A request to wp-cron.php runs the trunk, takes the doing_cron lock, fires each due event as an action, releases the lock, and exits. No admin hooks and no template hooks fire. We scheduled one event called hol_demo_event and requested wp-cron.php?doing_wp_cron directly.
# | Action | What belongs here |
|---|---|---|
1 |
| Plugin bootstrap. Your event callbacks must be attached by here or on |
2 |
| Theme setup. |
3 |
| Resolves to user 0. Cron has no logged-in user. |
4 |
| Registries. Post types exist before events run. |
5 |
| Everything loaded. |
6 |
| Core takes the cron lock. |
7 |
| The event is removed from (or rescheduled in) the cron array before it runs. |
8 |
| Your event callback. The hook name is the event name. |
9 |
| Lock released. |
10 |
| Cleanup. |
One change from older guides: since WordPress 6.9, the code that notices due events and spawns wp-cron.php runs on shutdown instead of wp_loaded, unless ALTERNATE_WP_CRON is on. The source comment gives the reason: the loopback request can take a second, and doing it on wp_loaded delayed the first byte of the page. In our front-end log, set_transient_doing_cron appeared after shutdown. Cron callbacks themselves still run in the separate wp-cron.php request, as in the table.
Why does my cron callback never run?
The usual cause is that the add_action() for the event sits in code that does not load during cron. A cron event is just do_action( 'your_event' ) fired after wp_loaded. If you attach the callback inside an admin_init callback, an is_admin() check, or a template_redirect handler, nothing is listening when wp-cron.php fires the event, and the event is removed from the queue anyway. Attach event callbacks at plugin load or on init, unconditionally.
// Always attached, on every request type.
add_action( 'acme_nightly_cleanup', 'acme_run_nightly_cleanup' );
// Schedule once, for example on activation.
register_activation_hook( __FILE__, function () {
if ( ! wp_next_scheduled( 'acme_nightly_cleanup' ) ) {
wp_schedule_event( time(), 'daily', 'acme_nightly_cleanup' );
}
} );
function acme_run_nightly_cleanup() {
// No current user here. Do not rely on current_user_can().
}Checked on 15 Nov 2026. The second cause is permissions: inside a cron callback get_current_user_id() returns 0, so a function that checks current_user_can( 'edit_posts' ) before doing work silently does nothing. Split the capability check from the work and call the work function directly from cron.
How do hook priority and accepted arguments work?
Priority sets the order of callbacks on the same hook: lower numbers run first, the default is 10, and callbacks with equal priority run in the order they were added. Accepted arguments sets how many of the hook’s values your callback receives. The default is 1, so you must ask for more.
// save_post passes three values: $post_id, $post, $update.
// Without the 4th argument (3), $post and $update never arrive.
add_action( 'save_post', 'acme_on_save', 20, 3 );
function acme_on_save( $post_id, $post, $update ) {
if ( wp_is_post_revision( $post_id ) || 'acme_event' !== $post->post_type ) {
return;
}
// ...
}Checked on 15 Nov 2026. Priority is also how some core behaviour is wired. Your theme does not call wp_enqueue_scripts directly: core attaches it to wp_head at priority 1, then prints the emoji detection script at 7, styles at 8 and head scripts at 9. That is why enqueueing a stylesheet on wp_head at priority 10 is too late for the head: the styles have already been printed, so your file ends up in the footer.
Use PHP_INT_MAX sparingly. It looks like a clean way to “run last”, but when two plugins both use it you are back to load order, and the next developer has no idea why. A specific number like 20 or 99 with a comment saying what you need to run after is easier to maintain.
Why does remove_action return false?
remove_action() returns false when the callback is not attached at that moment with that exact priority. There are two separate causes, and we reproduced both on the same 7.1.4 install: calling it before the callback was added, and calling it with a different priority than the one used to add it.
The timing trap: removing a theme callback from a plugin
Twenty Twenty-Five attaches its stylesheet like this in functions.php:
add_action( 'wp_enqueue_scripts', 'twentytwentyfive_enqueue_styles' );Plugins and mu-plugins load before the theme’s functions.php, so this at plugin load time has nothing to remove:
// In a plugin or mu-plugin, at file scope.
remove_action( 'wp_enqueue_scripts', 'twentytwentyfive_enqueue_styles' ); // falseResult in our test: remove_action() returned false and the front page still printed the twentytwentyfive-style stylesheet. We then moved the same call to after_setup_theme at priority 99, which fires after the theme’s functions.php is included:
add_action( 'after_setup_theme', function () {
remove_action( 'wp_enqueue_scripts', 'twentytwentyfive_enqueue_styles' ); // true
}, 99 );Result: true, and the stylesheet was gone from the page (0 matches). Checked on 15 Nov 2026. The rule: run the removal on a hook that fires after the code that added the callback and before the hook it is attached to. For theme callbacks that is after_setup_theme (later priority) or init. For callbacks another plugin adds on plugins_loaded, use plugins_loaded at a later priority, or init.
The priority trap: removing a core callback
Core adds the emoji detection script at priority 7, in wp-includes/default-filters.php:
add_action( 'wp_head', 'print_emoji_detection_script', 7 );Core’s default filters are attached before any plugin loads, so timing is not the problem. Priority is:
remove_action( 'wp_head', 'print_emoji_detection_script' ); // false: looks at priority 10
remove_action( 'wp_head', 'print_emoji_detection_script', 7 ); // trueBoth results are from the same request. Read the original add_action() call and copy its priority. If you cannot find it, has_action( 'wp_head', 'print_emoji_detection_script' ) returns the priority (7 here) instead of true. Checked on 15 Nov 2026.
What about callbacks added by class methods?
If a plugin adds array( $this, 'render' ), you need the same object instance to remove it, because a new instance of the class is a different callback. Look for a global, a singleton accessor like Plugin::instance(), or a filter the plugin offers. If none exist, the clean option is to ask the author for a hook. Walking $wp_filter to find the object works, but it breaks on the plugin’s next refactor. When we build free and pro plugin pairs we expose named instances for exactly this reason, which is part of the approach in coupling free and pro plugins without copying code.
Which hook should I use for common tasks?
Each row follows from the measured order above.
Task | Hook | Note |
|---|---|---|
Register a post type or taxonomy |
| Flush rewrite rules once on activation, never on every request. |
Load a plugin text domain |
| Plugins translated on WordPress.org do not need the call since 4.6. The 6.7 notice is about translating strings too early; see the problems section below. |
Theme supports, image sizes, menus |
| |
Front-end CSS and JS |
| Never |
Admin CSS and JS |
| Check |
Block editor assets |
| |
Admin menu pages |
| |
Settings API |
| Also |
REST routes |
| Always with a |
Front-end redirects and gating |
| |
Change the main query |
| With an |
Handle a front-end form POST |
| Nonce check, then redirect. |
Cron event callbacks | Plugin load or | Unconditionally. |
Logging after the response |
|
What breaks if I call these functions too early?
The errors we see most in code review, with the hook that fixes each:
is_user_logged_in()at plugin file scope: fatal “call to undefined function”, becausepluggable.phploads after plugin files. Move it toplugins_loadedor later.is_singular()oris_page()oninit: always false, the query has not run. Usewportemplate_redirect.get_current_screen()onadmin_init: returns null, the screen is set later. Usecurrent_screenorload-{$page_hook}.register_post_type()onplugins_loaded: works, but rewrite rules and translations are wrong. Useinit.wp_enqueue_style()onwp_footer: the style prints in the footer and the page flashes unstyled. Enqueue onwp_enqueue_scripts.
Common mistakes people report
These are the hook-timing problems that keep coming back in plugin issue trackers and the WordPress.org forums. Each one maps to a section above. Links checked on 15 Nov 2026.
- The removal that silently does nothing. A forum thread on remove_action not working shows a WooCommerce add-to-cart removal tried on
init,after_setup_themeandplugins_loaded, with a moderator pointing out the code may run before the callback was added. Fix: match the hook, the priority and the timing, as in the section onremove_action(). - Translations loaded too early. Since WordPress 6.7, translating a string for your text domain before the theme has loaded raises a notice that says translations should load at
initor later. Reports include WP Rocket issue 7102, a WP User Manager issue where add-ons loaded their domain too soon, and the WooCommerce developer advisory. In the 7.1.4 source the check is! doing_action( 'after_setup_theme' ) && ! did_action( 'after_setup_theme' ), so any translated string before that point triggers it. Fix: do not call__()at file scope or onplugins_loaded; translate when you render, oninitor later. - REST routes registered on the wrong hook. The notice about
rest_api_initis documented on the register_rest_route reference, and the permission variant added in 5.5 still shows up in threads such as this one for an authentication plugin. Fix: register onrest_api_init, always pass apermission_callback, and use__return_trueonly for routes that are truly public. - Asking “is this REST?” too early. The function reference states it should not be called before
parse_request, and our table above shows it returns false oniniteven for a real REST call. Fix: move the check torest_api_initor the route callback. - Heavy work on admin_init during AJAX. The core file
admin-ajax.phpfiresadmin_initfor logged-out visitors too (see the AJAX table). Fix: return early onwp_doing_ajax()for anything that is only meant for a screen.
That is five recurring problems: three with public issues or threads, one documented on the function reference, and one read straight from the core source.
How can I see the hook order on my own site?
Add a small must-use plugin that listens on the special all hook and records the first time each action fires. This is the file we used for the tables in this guide. Put it in wp-content/mu-plugins/hook-order-logger.php on a local or staging site, load the pages you care about, read the logs, then delete the file.
<?php
/**
* Plugin Name: Hook Order Logger (temporary)
* Logs the first time each action fires on a request. Remove after use.
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
$GLOBALS['hol_seen'] = array();
add_action( 'all', function ( $hook ) {
// Actions bump $wp_actions before the 'all' hook runs; filters do not.
if ( ! isset( $GLOBALS['wp_actions'][ $hook ] ) || isset( $GLOBALS['hol_seen'][ $hook ] ) ) {
return;
}
$GLOBALS['hol_seen'][ $hook ] = count( $GLOBALS['hol_seen'] ) + 1;
} );
register_shutdown_function( function () {
$uri = $_SERVER['REQUEST_URI'] ?? ( 'cli:' . implode( ' ', $GLOBALS['argv'] ?? array() ) );
$file = WP_CONTENT_DIR . '/hook-order-' . substr( md5( $uri . microtime() ), 0, 8 ) . '.log';
$out = '# ' . $uri . "\n";
foreach ( $GLOBALS['hol_seen'] as $hook => $n ) {
$out .= $n . "\t" . $hook . "\n";
}
file_put_contents( $file, $out );
} );Checked on 15 Nov 2026 (php -l clean on PHP 8.5.5). How it works: do_action() increments $wp_actions[ $hook ] before it calls the all hook, while apply_filters() does not touch that array. Checking $wp_actions is a cheap way to log actions and skip the hundreds of filters that fire on every page. Each request writes its own log file, so parallel requests (the page plus its REST and AJAX calls) do not overwrite each other.
Then request each type and read the logs:
# Front end, REST, cron (logged out)
curl -s -o /dev/null https://example.test/
curl -s -o /dev/null "https://example.test/wp-json/wp/v2/posts"
curl -s -o /dev/null "https://example.test/wp-cron.php?doing_wp_cron"
# Admin and AJAX need a logged-in cookie, so load those in the browser.
cat wp-content/hook-order-*.logChecked on 15 Nov 2026. Three limits to know. The logger starts at the first mu-plugin, so anything earlier (advanced-cache.php, db.php, multisite sunrise.php) is not in the log. The all hook adds overhead to every hook call, so never leave this on a production site. And on a real site the list will be much longer than ours, because every plugin adds its own actions. That is the point: the log shows where your plugins actually sit, not where a diagram says they should.
We ran the 7.1.4 tests on a throwaway install outside any other project (PHP built-in server, SQLite database, Twenty Twenty-Five, no other plugins) and deleted it afterwards. The tables above are from those logs; the source file for each hook was read from the 7.1.4 download.
Is Query Monitor a better option?
For day-to-day work, yes. Query Monitor’s “Hooks & Actions” panel lists every action that fired on the current page, with every callback attached to it, its priority and which plugin or theme added it. It answers “who is attached to this hook and at what priority” much faster than reading a log. The logger above is better for request types where you cannot see the panel, such as cron, or for comparing two requests in a diff. If you already use Query Monitor for performance work, our performance monitoring comparison covers how it fits next to New Relic and Datadog.
Frequently Asked Questions
What is the first hook a WordPress plugin can use?
For a regular plugin, the first useful hook is plugin_loaded (fired right after your own file is included) and then plugins_loaded (fired after all plugins). A must-use plugin loads earlier and can use muplugins_loaded. Anything before that point, such as advanced-cache.php, runs before the plugin API is available to plugins at all.
What is the difference between init and wp_loaded?
init is where plugins and themes register things: post types, taxonomies, shortcodes and blocks. wp_loaded fires right after init has finished for everyone, so it is the point where you can rely on all of those registrations being in place. Use init to register, and wp_loaded when you need to act on everything that was registered, such as handling a form submission that touches another plugin’s post type.
Does admin_init run on the front end?
Not on normal front-end page loads. It does run on every request to admin-ajax.php, including logged-out front-end AJAX calls, because those are admin requests. It does not run on REST API requests or cron. Our logs show admin_init in the admin and AJAX tables only.
Why does is_admin() return false in the block editor’s REST calls?
The block editor page is an admin page, but it saves and loads data through the REST API at /wp-json/, and those are separate HTTP requests. is_admin() checks whether the current request is for an admin screen, so it is false for every REST call. Use wp_is_serving_rest_request() from rest_api_init onward, or check the route, and put REST logic on rest_api_init.
Do hooks fire in the same order on every site?
The core sequence in the tables is the same everywhere, because it is fixed in wp-settings.php, wp-admin/admin.php, wp-includes/class-wp.php and the template loader. What changes per site is which extra actions fire between them (every plugin adds its own), the position of conditional ones like set_current_user, and the loop position on block versus classic themes. Run the logger on your own stack before relying on a specific detail.
When should I use did_action() instead of adding a hook?
Use did_action( 'init' ) when your code can be called at different times and must behave correctly either way. A common pattern in libraries: if init has already fired, register right away; otherwise attach to init. It returns the number of times the action has fired, so 0 means “not yet”.
if ( did_action( 'init' ) ) {
acme_register_types();
} else {
add_action( 'init', 'acme_register_types' );
}Checked on 15 Nov 2026. The order above is for WordPress 7.1.4, so re-run the logger after each major release if your plugin depends on a position between two hooks.





No comments yet