Remove api.w.org REST API/JSON API from WordPress header.

Harish Kumar · · 487 Views

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

  1. wp_oembed_add_discovery_links

  2. rest_output_link_wp_head

  3. rest_output_link_header

0

Please login or create new account to add your comment.

0 comments
You may also like:

Use Transients API Caching and Speed Up Your WordPress Theme.

The Transients API in WordPress is an effective method for saving cached data in the database. It allows us to take resource-intensive queries and store them in short-term caches (...)
Harish Kumar

How to Add Custom User Profile (User meta) Fields In WordPress

When you are focusing on tasks that need user management, and you need to add more fields for the user. In that case, here user meta functionality is used. This is similar to creating (...)
Harish Kumar

WordPress: How to Fix Missing required field entry-title, Update, hCard Error in Google Structured Data tool.

Recently when I tested one of my WordPress weblogs via Google Structured Data testing tools, I got the following errors:
Harish Kumar

How to fetch Any post with WP_Query in WordPress?

WP_Query is your buddy. It allows you to get content from the database according to your requirements. In this article, I will explain top to bottom about how WP_Query works. let’s (...)
Harish Kumar

How to Enable Featured Image in WordPress?

Featured Images or Post Thumbnails is a theme feature. Most themes such as Genesis and other themes support featured images by default. A great way to determine whether your theme (...)
Harish Kumar

Extend the where clause in WordPress WP_Query

In WordPress, sometimes needing to modify WP_Query class to interact with your database. For example, let's say you want to find all posts that the title would contain a specific (...)
Harish Kumar