The WordPress Request Lifecycle

Understand when WordPress loads each subsystem so custom code runs in the correct context and at the correct time.

2 min read

  • Article
  • Advanced
  • 2 minutes read
  • Reviewed August 4, 2026
  • Advanced WordPress and integrations

The WordPress request lifecycle is the sequence used to bootstrap the application, interpret the request and produce a response.

The exact path varies for frontend pages, administration screens, REST requests, AJAX, cron, XML-RPC and WP-CLI.

Entry and Configuration

A normal frontend request reaches index.php, which loads wp-blog-header.php and then the WordPress environment.

wp-load.php locates configuration. wp-settings.php initializes core services, plugins, the theme and important hooks.

Early Loading

The general order includes:

  • Core bootstrap.
  • advanced cache and database drop-ins.
  • object cache.
  • must-use plugins.
  • network-activated plugins.
  • normal active plugins.
  • pluggable functions.
  • theme setup.

Code that depends on another plugin should not assume PHP file order unless that dependency is defined explicitly.

Common Milestones

Important hooks include:

  • muplugins_loaded.
  • plugins_loaded.
  • setup_theme.
  • after_setup_theme.
  • init.
  • wp_loaded.

init fires after WordPress has loaded but before headers are sent. It is widely used for registering post types, taxonomies and rewrite structures.

Request Parsing and Main Query

The main WP object parses the URL into query variables.

WordPress then creates and runs the main WP_Query, determines the request type, prepares headers and selects a template.

Changes to the main query should generally use supported hooks such as pre_get_posts rather than replacing global objects late.

Alternative Contexts

REST requests pass through REST routing and endpoint callbacks.

Administration requests load screen-specific files and hooks. WP-CLI can bootstrap WordPress without a browser request. Cron and loopback requests use their own entry paths.

Use context checks carefully. is_admin() describes administration context, not whether the current user is an administrator.

Frequently Asked Questions

Is the lifecycle identical for every request?

No. REST, AJAX, cron, CLI and administration requests share bootstrap stages but diverge later.

Is init the earliest place to run plugin code?

No. Earlier hooks exist, but init is the correct public milestone for many registrations.

Continue Learning

Previous: WordPress Database Structure Explained

Next: The WordPress Hook Lifecycle