Attention Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Function Reference/wp remote request


Retrieve the raw response from the HTTP request.

The array structure is a little complex.

$res = array(
    'headers'  => array(),

    'response' => array(
        'code'    => int,
        'message' => string

All of the headers in $res['headers'] are with the name as the key and the value as the value. So to get the User-Agent, you would do the following.

$user_agent = $res['headers']['user-agent'];

The body is the raw response content and can be retrieved from $res['body']. This function is called first to make the request and there are other API functions to abstract out the above convoluted setup.


(string) (required) Site URL to retrieve.
Default: None
(array) (optional) Optional. Override the defaults.
Default: Array

Return Values


Change Log

Since: 2.7.0

Source File

wp_remote_request() is located in wp-includes/http.php