WP_REST_Response::remove_link( string $rel, string $href = null )

In this article

Removes a link from the response.

Parameters

$relstringrequired
Link relation. Either an IANA registered type, or an absolute URL.
$hrefstringoptional
Only remove links for the relation matching the given href.

Default:null

Source

public function remove_link( $rel, $href = null ) {
	if ( ! isset( $this->links[ $rel ] ) ) {
		return;
	}

	if ( $href ) {
		$this->links[ $rel ] = wp_list_filter( $this->links[ $rel ], array( 'href' => $href ), 'NOT' );
	} else {
		$this->links[ $rel ] = array();
	}

	if ( ! $this->links[ $rel ] ) {
		unset( $this->links[ $rel ] );
	}
}

Changelog

VersionDescription
4.4.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.