Title: wp_remote_retrieve_header
Published: April 25, 2014
Last modified: February 24, 2026

---

# wp_remote_retrieve_header( array|WP_Error $response, string $header ): array|string

## In this article

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

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

Retrieves a single header by name from the raw response.

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

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

HTTP response.

`$header`stringrequired

Header name to retrieve value from.

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

 array|string The header(s) value(s). Array if multiple headers with the same name
are retrieved.
 Empty string if incorrect parameter given, or if the header doesn’t
exist.

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

    ```php
    function wp_remote_retrieve_header( $response, $header ) {
    	if ( is_wp_error( $response ) || ! isset( $response['headers'] ) ) {
    		return '';
    	}

    	if ( isset( $response['headers'][ $header ] ) ) {
    		return $response['headers'][ $header ];
    	}

    	return '';
    }
    ```

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

## 󠀁[Related](https://developer.wordpress.org/reference/functions/wp_remote_retrieve_header/?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_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_install_maybe_enable_pretty_permalinks()](https://developer.wordpress.org/reference/functions/wp_install_maybe_enable_pretty_permalinks/)`wp-admin/includes/upgrade.php` |

Maybe enable pretty permalinks on installation.

  | 
| [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.

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

Finds a pingback server URI based on the given URL.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/wp_remote_retrieve_header/?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_header/?output_format=md#user-contributed-notes)󠁿

 1.  [Skip to note 2 content](https://developer.wordpress.org/reference/functions/wp_remote_retrieve_header/?output_format=md#comment-content-1497)
 2.   [Codex](https://profiles.wordpress.org/codex/)  [  10 years ago  ](https://developer.wordpress.org/reference/functions/wp_remote_retrieve_header/#comment-1497)
 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_header%2F%23comment-1497)
    Vote results for this note: 0[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_header%2F%23comment-1497)
 4. **Get last modified date from response header**
 5.     ```php
        $response = wp_remote_get( 'http://www.foo.com/file.txt' );
        $last_modified = wp_remote_retrieve_header( $response, 'last-modified' );
        ```
    
 6.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_remote_retrieve_header%2F%3Freplytocom%3D1497%23feedback-editor-1497)

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