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.
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It only takes a minute to sign up.
Sign up to join this communityI 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
object."
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.
$this->init();
$this->parse_request($query_args);
$this->send_headers();
$this->query_posts();
$this->handle_404();
$this->register_globals();
To get further details look through each of the methods, they are all in wp-includes/class-wp.php