Remove api.w.org REST API/JSON API from WordPress header.
WordPress uses the REST API since edition 4.4 of the CMS. It allows developers to interact with the WordPress back-end more quickly since this API is a standard way to connect. However, this also adds the following header to your Worpress website:
<head>
...
<link rel='https://api.w.org/' href='http://example.com/wp-json/' />
<link rel="alternate" type="application/json+oembed" href="http://example.com/wp-json/oembed/1.0/embed?url=..." />
<link rel="alternate" type="text/xml+oembed" href="http://example.com/wp-json/oembed/1.0/embed?url=..." />
</head>
To remove this added header from the WordPress website, you need to add the following lines of code in the functions.php
file within the WordPress theme’s directory.
remove_action( 'wp_head', 'rest_output_link_wp_head' );
remove_action( 'wp_head', 'wp_oembed_add_discovery_links' );
To remove the rest_output_link_header
remove_action( 'template_redirect', 'rest_output_link_header', 11, 0 );
Reference
Please login or create new account to add your comment.