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