3
WordPress不用插件如何去除头部多余的加载项
source link: https://www.huhexian.com/10302.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
WordPress不用插件如何去除头部多余的加载项
2021-11-1014:43:44评论1467字
我们是进行wordpress进行开发的时候,不知道有没有心细的小伙伴注意到网站的头部总会出现一些没有用的加载项,比如自带的css、js、feed、style等多余信息,那么我们可以删掉头部这些多余的插件吗?
其实很简单的,只要将下面代码复制到主题文件functions.php中即可
- remove_action( 'wp_head', 'wp_generator' );
- remove_action( 'wp_head', 'rsd_link' );
- remove_action( 'wp_head', 'wlwmanifest_link' );
- remove_action( 'wp_head', 'index_rel_link' );
- remove_action( 'wp_head', 'parent_post_rel_link', 10, 0 );
- remove_action( 'wp_head', 'start_post_rel_link', 10, 0 );
- 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', 'rest_output_link_wp_head', 10 );
- remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
- add_filter( 'show_admin_bar', '__return_false' );
- remove_action( 'wp_head', 'rel_canonical' );
- remove_action( 'wp_head', 'wp_shortlink_wp_head', 10, 0 );
- remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
- remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );
- remove_action( 'wp_print_styles', 'print_emoji_styles' );
- remove_action( 'admin_print_styles', 'print_emoji_styles' );
- remove_action( 'wp_head', 'rest_output_link_wp_head', 10 );
- remove_action('wp_head','wp_resource_hints',2);
保存后在看看你的网站源代码。是不是没有那些加载项。
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK