WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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 WordPress source code, there is one point I can not understand. In /wp-blog-header.php, there is a call to wp() function. However, I can not find any definition for that function. How this call don't cause error?

share|improve this question
up vote 3 down vote accepted

Just follow the code :).

Before calling wp(), /wp-blog-header.php loads /wp-load.php (which assuming you have correctly installed WordPress) loads /wp-config.php. At the bottom of that file, it calls /wp-settings.php.

This file loads a lot of other files, initialising the core parts of WordPress. Amongst them, is the wp-includes/functions.php file. It's inside this file that wp() is defined.

Once /wp-settings.php has finished loading all the files, wp() is then called - this 'starts' WordPress (interpreting the incoming url, processing it into a query, choosing a template and finally outputting the content and sending into the user.

share|improve this answer

You can see info about the wp() function on queryposts.com which also links to the function on trac. I also learned a surprising amount from Nacin's powerpoint slides from "You Don't Know Query" that discussion the wp() function starting on slide 29.

share|improve this answer
@tight slideshow! bookmarked. – Johannes Pille May 16 '12 at 3:05

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.