最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

How to remove rest api link: in http headers?

programmeradmin3浏览0评论

i would like to remove the "link:" line added to the http headers since wordpress 4.4

here is a

curl -I killcandida 

here is the output extract of the line that i would like to delete:

Link: </>; rel="/"

Note that i don't talk here about html headers but http headers.

i would like to remove the "link:" line added to the http headers since wordpress 4.4

here is a

curl -I killcandida 

here is the output extract of the line that i would like to delete:

Link: <http://killcandida/wp-json/>; rel="https://api.w/"

Note that i don't talk here about html headers but http headers.

Share Improve this question asked Dec 14, 2015 at 22:20 Nicolas GuérinetNicolas Guérinet 2642 gold badges5 silver badges12 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 17

The output is generated by the rest_output_link_header(). This function is used in two actions, wp_head and template_redirect in default-filters.php:@line234. You can remove the function from those hooks to remove the output you wanted to remove. Put the following codes in your theme's functions.php to achieve the desired result.

remove_action( 'wp_head', 'rest_output_link_wp_head', 10);    
remove_action( 'template_redirect', 'rest_output_link_header', 11);
  • rest_output_link_header
  • Remove WordPress JSON API links in header html

Both actions are defined in ABSPATH/wp-includes/default-filters.php under // REST API filters.

发布评论

评论列表(0)

  1. 暂无评论