WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In what order are plugins loaded in WordPress?

And within a particular plugin's folder, what order is followed for loading?

share|improve this question
You can debug very deeply with this plugin: https://wordpress.org/plugins/whats-running/ It lists all required files in WordPress. – Szépe Viktor Oct 25 '14 at 16:22
up vote 7 down vote accepted

First question:

In wp-settings.php, WordPress first checks for any must-use plugins (plugins in the optional mu-plugins folder) and loads those.

Then, if you're running a multisite installation, it checks for plugins that are network-activated and loads those.

Then it checks for all other active plugins by looking at the active_plugins entry of the wp_options database table, and loops through those. The plugins will be listed alphabetically.

Here's the order WordPress loads pretty much everything: http://codex.wordpress.org/Action_Reference#Actions_Run_During_a_Typical_Request

The thing is, it usually doesn't matter what order each individual plugin is loaded in, because properly-written plugins will use WordPress hooks, which let you plug in functionality into specific points later in the WordPress startup. (Properly-written plugins will also prefix their functions and classes so that there aren't any conflicts.)

More info on plugin API: http://codex.wordpress.org/Plugin_API/

Second question:

Totally depends on the plugin. WordPress only loads one file in the plugin, the one that's usually named the-plugin-name.php and contains the title, description, author, etc. at the top. It's up to the plugin to load the rest of its files, using require_once and wp_enqueue_script and whatnot.

share|improve this answer
So if I create a plugin, then later release an add-on plugins that should run after the original plugin is run, how can I ensure that order? – drtanz Aug 27 '12 at 6:21
It really depends what you're trying to do. But generally you would set up each of them to run on a specific hook using the add_action() function, which allows you to set priority. codex.wordpress.org/Function_Reference/add_action – SeventhSteel Aug 27 '12 at 13:31
@SeventhSteel But what if a plugin relies on the hook created by another plugin. If one plugin uses apply_filters() to create a hook, but runs before a plugin that uses add_filter(), then will it still work? Logically, it seems that apply_filters() will have fired already, so the add_filter() calls in the second plugin won't do anything. Does it matter in what order the plugins load when using only plugin-created hooks? – trusktr Jul 1 '13 at 17:15
What matters is what has loaded by the time apply_filters() runs. add_filter() must run before apply_filters(). If add_filter() is in a plugin file and not in another function, it will run on the plugins_loaded hook which is generally going to happen before you'd need apply_filters(). – SeventhSteel Nov 21 '14 at 17:28

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.