WP_REST_Response::link_header() WordPress Method
The WP_REST_Response::link_header() method is used to add a link header to a WP_REST_Response object. This is typically used to add pagination links to a response.
WP_REST_Response::link_header( string $rel, string $link, array $other = array() ) #
Sets a single link header.
Contents
Parameters
- $rel
(string)(Required)Link relation. Either an IANA registered type, or an absolute URL.
- $link
(string)(Required)Target IRI for the link.
- $other
(array)(Optional) Other parameters to send, as an associative array.
Default value: array()
Source
File: wp-includes/rest-api/class-wp-rest-response.php
public function link_header( $rel, $link, $other = array() ) { $header = '<' . $link . '>; rel="' . $rel . '"'; foreach ( $other as $key => $value ) { if ( 'title' === $key ) { $value = '"' . $value . '"'; } $header .= '; ' . $key . '=' . $value; } $this->header( 'Link', $header, false ); }
Expand full source codeCollapse full source codeView on TracView on GitHub
Changelog
Version | Description |
---|---|
4.4.0 | Introduced. |