do_action( 'init' )

Fires after WordPress has finished loading but before any headers are sent.


Description Description

Most of WP is loaded at this stage, and the user is authenticated. WP continues to load on the ‘init’ hook that follows (e.g. widgets), and many plugins instantiate themselves on it for all sorts of reasons (e.g. they need a user, a taxonomy, etc.).

If you wish to plug an action once WP is loaded, use the ‘wp_loaded’ hook below.


Source Source

File: wp-settings.php

View on Trac


Top ↑

Changelog Changelog

Changelog
Version Description
1.5.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

  1. Skip to note 1 content
    Contributed by Rnaby

    This hook works almost like the admin_init hook. The difference is the admin_init fires on the initialization of admin screen or scripts and this init hook fires on the initialization time of the whole WordPress script. Like-

    /**
     * Fire on the initialization of WordPress.
     */
    function the_dramatist_fire_on_wp_initialization() {
        // Do stuff. Say we will echo "Fired on the WordPress initialization".
        echo 'Fired on the WordPress initialization';
    }
    add_action( 'init', 'the_dramatist_fire_on_wp_initialization' );
    

    Now the above code will echo “Fired on the WordPress initialization” on initialization of WordPress.

You must log in before being able to contribute a note or feedback.