WordPress 程序搭建的网站查看源码时会发现头部的 html 代码非常多,包括版本号、前后文、第一篇文章、主页 meta 信息等各种冗余代码,这些代码其实是不必加载的,也对网站的安全有一定的影响,荒岛本次带来 WordPress 移除头部冗余代码的教程,只要将下面的代码添加到主题的「functions.php」文件即可。
// 荒岛一座藏有宝藏的小岛 remove_action( 'wp_head', 'wp_generator' ); remove_action( 'wp_head', 'rsd_link' ); remove_action( 'wp_head', 'wlwmanifest_link' ); remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0 ); remove_action( 'wp_head', 'feed_links', 2 ); remove_action( 'wp_head', 'feed_links_extra', 3 ); remove_action( 'wp_head', 'wp_shortlink_wp_head', 10, 0 ); remove_action('template_redirect','wp_shortlink_header',11,0);宝藏内容来自荒岛-https://x-imagine.com/wordpress-remove-head-voice-code-tutorial.html宝藏内容来自荒岛-https://x-imagine.com/wordpress-remove-head-voice-code-tutorial.html
请按 Ctrl+D 收藏荒岛分享给好友 如您发现本文件已经失效无法下载请联系站长修正
荒岛公众号
扫一扫关注

HDsoft27
公众号ID已复制,前往微信关注...
荒岛小程序
扫一扫关注

ximagine
哔哩姬ID已复制,前往B站关注...