Uses
Uses | Description |
---|---|
wp-includes/rest-api/class-wp-rest-response.php: WP_REST_Response::add_link() | Adds a link to the response. |
Adds multiple links to the response.
Link data should be an associative array with link relation as the key. The value can either be an associative array of link attributes (including href
with the URL for the response), or a list of these associative arrays.
(array) (Required) Map of link relation to list of links.
File: wp-includes/rest-api/class-wp-rest-response.php
public function add_links( $links ) { foreach ( $links as $rel => $set ) { // If it's a single link, wrap with an array for consistent handling. if ( isset( $set['href'] ) ) { $set = array( $set ); } foreach ( $set as $attributes ) { $this->add_link( $rel, $attributes['href'], $attributes ); } } }
Version | Description |
---|---|
4.4.0 | Introduced. |
© 2003–2019 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_rest_response/add_links