Bootstrap

Every WordPress request boots in the same strict order: must-use plugins, then regular plugins, then the theme, then WordPress itself. These hooks mark each stage — get the order wrong and your code breaks unpredictably depending on what else is installed. 6 actions, 0 filters in this category.

Watch the summary

muplugins_loaded

bootstrap

Fires right after mu-plugins load — the true first hook of the request

muplugins_loaded is the earliest action in the entire WordPress bootstrap — it fires right after must-use (mu-plugins) and network-activated plugins are loaded, before a single regular plugin has run. Almost nobody hooks it, which is exactly why it makes a great trivia question.

Signature

do_action( 'muplugins_loaded' );

Example

add_action( 'muplugins_loaded', function() {
    error_log( 'Bootstrap started.' );
} );

Common Use Cases

  • Bootstrap code that must run before any regular plugin
  • Define constants needed by plugins loaded afterward
  • Multisite: react to network-activated plugins having loaded
  • Mark a precise start-of-bootstrap timestamp for performance profiling
since 2.8.0wp-settings.php

plugins_loaded

bootstrap

Fires once all active plugins have loaded

plugins_loaded is the earliest point where every active plugin's functions and classes are guaranteed to exist — use it for cross-plugin checks, not for registering WordPress objects.

Signature

do_action( 'plugins_loaded' );

Example

add_action( 'plugins_loaded', function() {
    if ( class_exists( 'WooCommerce' ) ) {
        require_once __DIR__ . '/integrations/woocommerce.php';
    }
} );

Common Use Cases

  • Check if another plugin/class exists
  • Load plugin translations
  • Bootstrap plugin dependencies
  • Set up autoloaders
since 1.5.0wp-settings.php

after_setup_theme

bootstrap

Fires after the theme is loaded, before init

after_setup_theme is where themes declare support for core features — post thumbnails, menus, HTML5 markup — before WordPress finishes bootstrapping.

Signature

do_action( 'after_setup_theme' );

Example

add_action( 'after_setup_theme', function() {
    add_theme_support( 'post-thumbnails' );
    add_theme_support( 'title-tag' );
    register_nav_menus( [ 'primary' => 'Primary Menu' ] );
} );

Common Use Cases

  • Declare add_theme_support() features
  • Register nav menu locations
  • Set content width
  • Load theme text domain
since 2.6.0wp-settings.php

init

bootstrap

Runs after WordPress has finished loading

init is the default place to register post types, taxonomies, and rewrite-related APIs. It fires after plugins are loaded and before headers go out.

Signature

do_action( 'init' );

Example

add_action( 'init', function() {
    register_post_type( 'book', [
        'public' => true,
        'label'  => 'Books',
    ] );
} );

Common Use Cases

  • Register custom post types
  • Register custom taxonomies
  • Start sessions
  • Load text domains (plugins)
since 0.71wp-settings.php

widgets_init

bootstrap

Fires when it's time to register widgets and sidebars

widgets_init is exclusively for register_sidebar() and register_widget() calls — nothing else belongs here.

Signature

do_action( 'widgets_init' );

Example

add_action( 'widgets_init', function() {
    register_sidebar( [
        'name' => 'Footer Widgets',
        'id'   => 'footer-widgets',
        'before_widget' => '<div class="widget %2$s">',
        'after_widget'  => '</div>',
    ] );
} );

Common Use Cases

  • Register sidebar/widget areas
  • Register custom WP_Widget classes
  • Unregister default widgets
since 2.2.0wp-includes/widgets.php

wp_loaded

bootstrap

Fires once WordPress, plugins, and theme are fully loaded

wp_loaded runs after every init callback has finished — use it when your code depends on things other plugins register on init.

Signature

do_action( 'wp_loaded' );

Example

add_action( 'wp_loaded', function() {
    if ( ! post_type_exists( 'book' ) ) {
        return;
    }
    flush_rewrite_rules();
} );

Common Use Cases

  • Read config set by other plugins on init
  • Conditional logic that depends on registered post types/taxonomies
  • Late-stage bootstrap checks
since 3.0.0wp-settings.php