最近升級WordPress,wordpress增加了REST API無用鏈接,這里介紹兩種方法刪除的方法。只需要使用下面的一種即可。 代碼如下!將下面代碼添加到主題functions.php文件中禁用REST API功能,并且不在head輸出鏈接信息。
1.禁用REST API
- add_filter('rest_enabled', '_return_false'); add_filter('rest_jsonp_enabled', '_return_false');
2.移除wp-json鏈接
將下面代碼添加到主題functions.php文件中,去除head里面輸出的鏈接信息。介紹兩種方法
- remove_action( 'wp_head', 'rest_output_link_wp_head', 10 ); remove_action( 'wp_head', 'wp_oembed_add_discovery_links', 10 );
新聞熱點
疑難解答
圖片精選