Use the code PERFMATTERS for 10% off!

How to Remove WordPress REST API Links

The WordPress REST API enables the CMS to communicate with other web properties, no matter what programming language they’re written in. According to the WordPress handbook:

The WordPress REST API provides API endpoints for WordPress data types that allow developers to interact with sites remotely by sending and receiving JSON (JavaScript Object Notation) objects.

However, a lot of sites don’t use this, and therefore in most cases, it is just unnecessary code. By default, every site includes a link in the header:

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

There is also a header that is sent on each request:

function rest_output_link_header() {
 if ( headers_sent() ) {
 $api_root = get_rest_url();
 if ( empty( $api_root ) ) {

There is also an API tag that gets added to the Really Simple Discovery (RSD) endpoint.

<api name="WP-API" blogID="1" preferred="false" apiLink="<?php echo esc_url( $api_root ); ?>" />

You can easily remove WordPress REST API links by enabling the “Remove REST API Links” option.

Remove WordPress REST API links in header
Remove WordPress REST API links in header

The above only removes the front-end code. Check out our article on how to completely disable the WordPress REST API.

Was this article helpful?

Related Articles