Action Hook since 3.0.0

wp_loaded

Fires once WordPress, plugins, and theme are fully loaded

Description

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

When it runs

After init and all its callbacks; before the main query (parse_request) executes on the front-end.

Signature

do_action( 'wp_loaded' );

Examples

Basic

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

Safely check that a CPT registered on init before acting on it.

Common Use Cases

  • Read config set by other plugins on init
  • Conditional logic that depends on registered post types/taxonomies
  • Late-stage bootstrap checks

Common mistakes

  • Registering post types here — too late, rewrite rules for them won't be ready on this request

Related hooks

FAQ

What's the difference between init and wp_loaded?

init runs first and is where you register things; wp_loaded runs after all init callbacks finished, so it's safer for code that reads what other plugins registered.

Source: wp-settings.php

Group wizard

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

wp_loaded → init

functions.php — wp_loaded
functions.php
PHP wp_loaded · Hook 1 of 2 · Step 1 of 7

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