This global variable prepares everything for posts to be displayed. It gets user information, parses the request, sends headers, gets the posts and registers the globals. It is an instance of class WP which is declared in [wordpress root folder]/wp-includes/classes.php. The global variable is initialized in [wordpress root folder]/wp-settings.php.
This variable need not be directly accessed, [wordpress root folder]/functions.php provides the function wp($query_vars=”) which executes the method main($query_vars=”) to perform all the activities. Methods of this WP class are:
- parse_request($extra_query_vars=”)
- send_headers()
- build_query_string()
- register_globals()
- init()
- query_posts()
- handle_404()
- main($query_args=”)
- WP() - the Constructor
Plugin authors don’t have to use this, they can use the global function query_posts($query), defined in [wp root folder]/wp-includes/functions.php, to make a custom query for posts.
Back to full list of global variables.
Technorati tags: wp


March 2nd, 2006 at 6:18 pm
[...] $wp [...]
November 24th, 2006 at 2:18 pm
[...] Behavior Variables: wp_filter, richedit, page_cache, pagenow, wp_version, table_prefix,wp,admin_page_hooks, wp_object_cache, allowedposttags, allowedtags, and wp_rewrite [...]