I am learning WordPress and I find that in wp-blog-header.php a function wp(); is defined.

I find that it is defined in functions.php. Could someone tell me what exactly this function do. The Codex always look Greek or Latin to me.


From the WordPress source code: "Set up the WordPress query." (wp-includes/functions.php)

The wp() method in turn calls the WP->main (wp-includes/class-wp.php), which has the following description:

 "Sets up all of the variables required by the WordPress environment.

  The action 'wp' has one parameter that references the WP object. It
  allows for accessing the properties and methods to further manipulate the

This appears to be sort of a "boot" sequence for wordpress. Parsing the query parameters passed in the url, applying http headers to the response (this includes setting the X-pingback header for pingbacks), setting up the post query ($wp_query and $wp_the_query variables) if applicable, setting up 404 handling and registering global variables/constants.


To get further details look through each of the methods, they are all in wp-includes/class-wp.php

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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