WordPress at Your Fingertips
function is not described

WP_REST_Request::get_header() public WP 4.4.0

Retrieves the given header from the request.

If the header has multiple values, they will be concatenated with a comma as per the HTTP specification. Be aware that some non-compliant headers (notably cookie headers) cannot be joined this way.

{} It's a method of the class: WP_REST_Request{}

No Hooks.


String|null. String value if set, null otherwise.


$WP_REST_Request = new WP_REST_Request();
$WP_REST_Request->get_header( $key );
$key(string) (required)
Header name, will be canonicalized to lowercase.


Since 4.4.0 Introduced.

Code of WP_REST_Request::get_header() WP 5.8

public function get_header( $key ) {
	$key = $this->canonicalize_header_name( $key );

	if ( ! isset( $this->headers[ $key ] ) ) {
		return null;

	return implode( ',', $this->headers[ $key ] );