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

Customer asks if a specific carousel plugin he uses can be widgetized. That means i should create a widget inside functions.php which calls the plugin's function. That means that the plugin's code has to be loaded first so that the function be available to wordpress when the functions.php file is loaded, right? Would that work?

share|improve this question
up vote 102 down vote accepted

The plugins are loaded right before theme (yes, I've been looking for excuse to use this):

enter image description here

However it is wrong to think about either as point of code execution. For most cases everything should be hooked and executed no earlier than init hook. According to Codex widget registration with register_widget() should be hooked to widget_init.

Because of that order of load doesn't matter for this case, you will have everything loaded by the time widget needs it in any case.

share|improve this answer
Pretty image FTW! – Chip Bennett Aug 23 '11 at 1:42
Incredible. Great work. – Foxinni Aug 14 '12 at 11:43
WP core load will never make any sense. – gagarine Aug 27 '15 at 13:45
Any chance we can get an updated chart in 2016? ;-) – jgraup Jan 10 at 15:04
@jgraup you say that like things change in WordPress core... :) – Rarst Jan 10 at 21:19

You can have a widget inside the plugin's .php file (and have a shared global variable which they can both use), if that's what you're asking. Here's a tutorial with sample code I stumbled upon a while back.

Also, here's a list of actions run during a typical request, in order of execution. #2 and #10 suggest that plugins load first; not sure about functions.php.

share|improve this answer
Correct, plugins are loaded before theme files. If the plugin includes code, but not the widget you want, it is possible to define the widget in your theme's functions.php. – goldenapples Aug 22 '11 at 23:47

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.