rest_output_link_wp_head()WP 4.4.0

Displays a link to the root REST API route in the <head> section on all site pages.

The link looks like:

<link rel='' href='' />

This link is a notification to client applications that the current site has its own API.

By default, this function is called via wp_head hook

add_action( 'wp_head', 'rest_output_link_wp_head', 10, 0 );

A similar link is added to the server response headers by the rest_output_link_header() function that by default is called on the following hook:

add_action( 'template_redirect', 'rest_output_link_header', 11, 0 );
1 time — 0.004168 sec (very slow) | 50000 times — 4.19 sec (fast) | PHP 7.1.11, WP 4.9.8

No Hooks.


null. Nothing.




#1 Remove the REST API link

The below code does not disable the REST API but only cancels the link output on all pages of the site. This code can be inserted into a plugin or theme's functions.php file.

remove_action( 'wp_head', 'rest_output_link_wp_head' );



Since 4.4.0 Introduced.

Code of rest_output_link_wp_head() WP 6.0

function rest_output_link_wp_head() {
	$api_root = get_rest_url();

	if ( empty( $api_root ) ) {

	printf( '<link rel="" href="%s" />', esc_url( $api_root ) );

	$resource = rest_get_queried_resource_route();

	if ( $resource ) {
		printf( '<link rel="alternate" type="application/json" href="%s" />', esc_url( rest_url( $resource ) ) );