On this page
WP::main( string|array $query_args = '' )
Sets up all of the variables required by the WordPress environment.
Description
The action ‘wp’ has one parameter that references the WP object. It allows for accessing the properties and methods to further manipulate the object.
Parameters
$query_argsstring|array Optional-
Passed to parse_request().
Default:
''
Source
File: wp-includes/class-wp.php. View all references
public function main( $query_args = '' ) {
$this->init();
$parsed = $this->parse_request( $query_args );
if ( $parsed ) {
$this->query_posts();
$this->handle_404();
$this->register_globals();
}
$this->send_headers();
/**
* Fires once the WordPress environment has been set up.
*
* @since 2.1.0
*
* @param WP $wp Current WordPress environment instance (passed by reference).
*/
do_action_ref_array( 'wp', array( &$this ) );
}
Hooks
- do_action_ref_array( 'wp',
WP $wp ) -
Fires once the WordPress environment has been set up.
Related
Uses
| Uses | Description |
|---|---|
| WP::init() wp-includes/class-wp.php | Set up the current user. |
| WP::query_posts() wp-includes/class-wp.php | Set up the Loop based on the query variables. |
| WP::handle_404() wp-includes/class-wp.php | Set the Headers for 404, if nothing is found for requested URL. |
| WP::register_globals() wp-includes/class-wp.php | Set up the WordPress Globals. |
| WP::parse_request() wp-includes/class-wp.php | Parses the request to find the correct WordPress query. |
| WP::send_headers() wp-includes/class-wp.php | Sends additional HTTP headers for caching, content type, etc. |
| do_action_ref_array() wp-includes/plugin.php | Calls the callback functions that have been added to an action hook, specifying arguments in an array. |
Used By
| Used By | Description |
|---|---|
| wp() wp-includes/functions.php | Sets up the WordPress query. |
Changelog
| Version | Description |
|---|---|
| 2.0.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp/main