Remove REST API Link Tag from WP Site Header

In one of my previous post, I discussed how to disable REST API in WP. Unfortunately, disabling the REST-API does not remove the API link tag on the the header section of your WP site. So, basically we are showing a link tag on our site's header section that doesn't have any function whatsoever.

Now, this is how the link tag shows up on WordPress based site's header.

<link rel='https://api.w.org/' href='https://yourdomain.com/wp-json/' />
In order to remove the tag simply place the following snippet on your current theme's functions.php page and you are good to go.
<?php remove_action('wp_head','rest_output_link_wp_head', 10 ); ?>

What we are doing here is fairly simple. We are removing rest_output_link_header function from our site's header. This function is responsible for generating the tag line which has been introduced since WordPress 4.4. Hope this post helps someone.

Related

Comments

Comments list