Home » Hooks » plugins_loaded

The plugins_loaded hook in WordPress is a fundamental hook that is called after all of the active plugins are loaded. At this point, WordPress has finished loading all of the plugins and their respective functions. This hook is typically used by developers who are creating plugins to ensure that all of the necessary files and functions are loaded before their plugin runs.

The plugins_loaded hook allows developers to perform actions that need to be executed after the plugins are loaded but before the WordPress theme is loaded. This is particularly useful for developers who need to modify how WordPress works or add new functionality to the site.

Example Usage Code:

function my_plugin_function() {
    // Do something after all the plugins are loaded
add_action( 'plugins_loaded', 'my_plugin_function' );

In this example, we have created a function called my_plugin_function. We then use the add_action function to register the my_plugin_function function to be executed after all the plugins are loaded using the plugins_loaded hook. This ensures that the function runs only after the plugins have been loaded, but before the theme is loaded.

Learn More on

WordPress snippets using the plugins_loaded hook

Register an account to save your snippets or go Pro to get more features.