Title: WP_REST_Response::remove_link
Published: December 9, 2015
Last modified: February 24, 2026

---

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

## In this article

 * [Parameters](https://developer.wordpress.org/reference/classes/wp_rest_response/remove_link/?output_format=md#parameters)
 * [Source](https://developer.wordpress.org/reference/classes/wp_rest_response/remove_link/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/classes/wp_rest_response/remove_link/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/classes/wp_rest_response/remove_link/?output_format=md#changelog)

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

Removes a link from the response.

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

 `$rel`stringrequired

Link relation. Either an IANA registered type, or an absolute URL.

`$href`string|nulloptional

Only remove links for the relation matching the given href.

Default:`null`

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

    ```php
    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 ] );
    	}
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/rest-api/class-wp-rest-response.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/rest-api/class-wp-rest-response.php#L83)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/rest-api/class-wp-rest-response.php#L83-L97)

## 󠀁[Related](https://developer.wordpress.org/reference/classes/wp_rest_response/remove_link/?output_format=md#related)󠁿

| Uses | Description | 
| [wp_list_filter()](https://developer.wordpress.org/reference/functions/wp_list_filter/)`wp-includes/functions.php` |

Filters a list of objects, based on a set of key => value arguments.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/classes/wp_rest_response/remove_link/?output_format=md#changelog)󠁿

| Version | Description | 
| [4.4.0](https://developer.wordpress.org/reference/since/4.4.0/) | Introduced. |

## User Contributed Notes

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