Title: wp_remote_retrieve_response_code
Published: April 25, 2014
Last modified: May 20, 2026

---

# wp_remote_retrieve_response_code( array|WP_Error $response ): int|string

## In this article

 * [Description](https://developer.wordpress.org/reference/functions/wp_remote_retrieve_response_code/?output_format=md#description)
 * [Parameters](https://developer.wordpress.org/reference/functions/wp_remote_retrieve_response_code/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/wp_remote_retrieve_response_code/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/wp_remote_retrieve_response_code/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/wp_remote_retrieve_response_code/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/wp_remote_retrieve_response_code/?output_format=md#changelog)
 * [User Contributed Notes](https://developer.wordpress.org/reference/functions/wp_remote_retrieve_response_code/?output_format=md#user-contributed-notes)

[ Back to top](https://developer.wordpress.org/reference/functions/wp_remote_retrieve_response_code/?output_format=md#wp--skip-link--target)

Retrieves only the response code from the raw response.

## 󠀁[Description](https://developer.wordpress.org/reference/functions/wp_remote_retrieve_response_code/?output_format=md#description)󠁿

Will return an empty string if incorrect parameter value is given.

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/wp_remote_retrieve_response_code/?output_format=md#parameters)󠁿

 `$response`array|[WP_Error](https://developer.wordpress.org/reference/classes/wp_error/)
required

HTTP response.

## 󠀁[Return](https://developer.wordpress.org/reference/functions/wp_remote_retrieve_response_code/?output_format=md#return)󠁿

 int|string The response code as an integer. Empty string if incorrect parameter
given.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/wp_remote_retrieve_response_code/?output_format=md#source)󠁿

    ```php
    function wp_remote_retrieve_response_code( $response ) {
    	if ( is_wp_error( $response ) || ! isset( $response['response'] ) || ! is_array( $response['response'] ) ) {
    		return '';
    	}

    	return $response['response']['code'];
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/http.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.0/src/wp-includes/http.php#L282)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.0/src/wp-includes/http.php#L282-L288)

## 󠀁[Related](https://developer.wordpress.org/reference/functions/wp_remote_retrieve_response_code/?output_format=md#related)󠁿

| Uses | Description | 
| [is_wp_error()](https://developer.wordpress.org/reference/functions/is_wp_error/)`wp-includes/load.php` |

Checks whether the given variable is a WordPress Error.

  |

| Used by | Description | 
| [WP_AI_Client_HTTP_Client::create_psr_response()](https://developer.wordpress.org/reference/classes/wp_ai_client_http_client/create_psr_response/)`wp-includes/ai-client/adapters/class-wp-ai-client-http-client.php` |

Creates a PSR-7 response from a WordPress HTTP response.

  | 
| [WP_Font_Collection::load_from_url()](https://developer.wordpress.org/reference/classes/wp_font_collection/load_from_url/)`wp-includes/fonts/class-wp-font-collection.php` |

Loads the font collection data from a JSON file URL.

  | 
| [wp_get_https_detection_errors()](https://developer.wordpress.org/reference/functions/wp_get_https_detection_errors/)`wp-includes/https-detection.php` |

Runs a remote HTTPS request to detect whether HTTPS supported, and stores potential errors.

  | 
| [WP_Site_Health::check_for_page_caching()](https://developer.wordpress.org/reference/classes/wp_site_health/check_for_page_caching/)`wp-admin/includes/class-wp-site-health.php` |

Checks if site has page cache enabled or not.

  | 
| [WP_REST_URL_Details_Controller::get_remote_url()](https://developer.wordpress.org/reference/classes/wp_rest_url_details_controller/get_remote_url/)`wp-includes/rest-api/endpoints/class-wp-rest-url-details-controller.php` |

Retrieves the document title from a remote URL.

  | 
| [WP_Site_Health::wp_cron_scheduled_check()](https://developer.wordpress.org/reference/classes/wp_site_health/wp_cron_scheduled_check/)`wp-admin/includes/class-wp-site-health.php` |

Runs the scheduled event to check and update the latest site health status for the website.

  | 
| [WP_Site_Health::get_test_rest_availability()](https://developer.wordpress.org/reference/classes/wp_site_health/get_test_rest_availability/)`wp-admin/includes/class-wp-site-health.php` |

Tests if the REST API is accessible.

  | 
| [WP_Site_Health::can_perform_loopback()](https://developer.wordpress.org/reference/classes/wp_site_health/can_perform_loopback/)`wp-admin/includes/class-wp-site-health.php` |

Runs a loopback test on the site.

  | 
| [wp_check_php_version()](https://developer.wordpress.org/reference/functions/wp_check_php_version/)`wp-admin/includes/misc.php` |

Checks if the user needs to update PHP.

  | 
| [WP_Community_Events::get_events()](https://developer.wordpress.org/reference/classes/wp_community_events/get_events/)`wp-admin/includes/class-wp-community-events.php` |

Gets data about events near a particular location.

  | 
| [populate_network()](https://developer.wordpress.org/reference/functions/populate_network/)`wp-admin/includes/schema.php` |

Populate network settings.

  | 
| [get_core_checksums()](https://developer.wordpress.org/reference/functions/get_core_checksums/)`wp-admin/includes/update.php` |

Gets and caches the checksums for the given version of WordPress.

  | 
| [wp_check_browser_version()](https://developer.wordpress.org/reference/functions/wp_check_browser_version/)`wp-admin/includes/dashboard.php` |

Checks if the user needs a browser update.

  | 
| [download_url()](https://developer.wordpress.org/reference/functions/download_url/)`wp-admin/includes/file.php` |

Downloads a URL to a local temporary file using the WordPress HTTP API.

  | 
| [wp_credits()](https://developer.wordpress.org/reference/functions/wp_credits/)`wp-admin/includes/credits.php` |

Retrieves the contributor credits.

  | 
| [url_is_accessable_via_ssl()](https://developer.wordpress.org/reference/functions/url_is_accessable_via_ssl/)`wp-includes/deprecated.php` |

Determines if the URL can be accessed over SSL.

  | 
| [wp_get_http()](https://developer.wordpress.org/reference/functions/wp_get_http/)`wp-includes/deprecated.php` |

Perform a HTTP HEAD or GET request.

  | 
| [WP_SimplePie_File::__construct()](https://developer.wordpress.org/reference/classes/wp_simplepie_file/__construct/)`wp-includes/class-wp-simplepie-file.php` |

Constructor.

  | 
| [wp_version_check()](https://developer.wordpress.org/reference/functions/wp_version_check/)`wp-includes/update.php` |

Checks WordPress version against the newest version.

  | 
| [wp_update_plugins()](https://developer.wordpress.org/reference/functions/wp_update_plugins/)`wp-includes/update.php` |

Checks for available updates to plugins based on the latest versions hosted on WordPress.org.

  | 
| [wp_update_themes()](https://developer.wordpress.org/reference/functions/wp_update_themes/)`wp-includes/update.php` |

Checks for available updates to themes based on the latest versions hosted on WordPress.org.

  | 
| [WP_oEmbed::_fetch_with_format()](https://developer.wordpress.org/reference/classes/wp_oembed/_fetch_with_format/)`wp-includes/class-wp-oembed.php` |

Fetches result from an oEmbed provider for a specific format and complete provider URL

  | 
| [WP_HTTP_IXR_Client::query()](https://developer.wordpress.org/reference/classes/wp_http_ixr_client/query/)`wp-includes/class-wp-http-ixr-client.php` |  | 
| [_fetch_remote_file()](https://developer.wordpress.org/reference/functions/_fetch_remote_file/)`wp-includes/rss.php` |

Retrieve URL headers and content using WP HTTP Request API.

  |

[Show 19 more](https://developer.wordpress.org/reference/functions/wp_remote_retrieve_response_code/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/functions/wp_remote_retrieve_response_code/?output_format=md#)

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/wp_remote_retrieve_response_code/?output_format=md#changelog)󠁿

| Version | Description | 
| [2.7.0](https://developer.wordpress.org/reference/since/2.7.0/) | Introduced. |

## 󠀁[User Contributed Notes](https://developer.wordpress.org/reference/functions/wp_remote_retrieve_response_code/?output_format=md#user-contributed-notes)󠁿

 1.  [Skip to note 2 content](https://developer.wordpress.org/reference/functions/wp_remote_retrieve_response_code/?output_format=md#comment-content-1445)
 2.   [Codex](https://profiles.wordpress.org/codex/)  [  10 years ago  ](https://developer.wordpress.org/reference/functions/wp_remote_retrieve_response_code/#comment-1445)
 3. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_remote_retrieve_response_code%2F%23comment-1445)
    Vote results for this note: 1[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_remote_retrieve_response_code%2F%23comment-1445)
 4. **Examples**
 5.     ```php
        $response = wp_remote_get( 'http://www.foo.com/file.txt' );
        $response_code = wp_remote_retrieve_response_code( $response );
        ```
    
 6. `$response_code` will contain a string representing the numeric response code sent
    from the server
 7.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_remote_retrieve_response_code%2F%3Freplytocom%3D1445%23feedback-editor-1445)

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_remote_retrieve_response_code%2F)
before being able to contribute a note or feedback.