wp

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-includes/functions.php, to make a custom query for posts.

Back to full list of global variables.

Technorati tags:

One Response to “wp”


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: