3

WordPress不用插件如何去除头部多余的加载项

 2 years ago
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.
neoserver,ios ssh client

WordPress不用插件如何去除头部多余的加载项

2021-11-1014:43:44评论1467字

我们是进行wordpress进行开发的时候,不知道有没有心细的小伙伴注意到网站的头部总会出现一些没有用的加载项,比如自带的css、js、feed、style等多余信息,那么我们可以删掉头部这些多余的插件吗?

WordPress不用插件如何去除头部多余的加载项

其实很简单的,只要将下面代码复制到主题文件functions.php中即可

  1. remove_action( 'wp_head', 'wp_generator' );
  2. remove_action( 'wp_head', 'rsd_link' );
  3. remove_action( 'wp_head', 'wlwmanifest_link' );
  4. remove_action( 'wp_head', 'index_rel_link' );
  5. remove_action( 'wp_head', 'parent_post_rel_link', 10, 0 );
  6. remove_action( 'wp_head', 'start_post_rel_link', 10, 0 );
  7. remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0 );
  8. remove_action( 'wp_head', 'feed_links', 2 );
  9. remove_action( 'wp_head', 'feed_links_extra', 3 );
  10. remove_action( 'wp_head', 'rest_output_link_wp_head', 10 );
  11. remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
  12. add_filter( 'show_admin_bar', '__return_false' );
  13. remove_action( 'wp_head', 'rel_canonical' );
  14. remove_action( 'wp_head', 'wp_shortlink_wp_head', 10, 0 );
  15. remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
  16. remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );
  17. remove_action( 'wp_print_styles', 'print_emoji_styles' );
  18. remove_action( 'admin_print_styles', 'print_emoji_styles' );
  19. remove_action( 'wp_head', 'rest_output_link_wp_head', 10 );
  20. remove_action('wp_head','wp_resource_hints',2);

保存后在看看你的网站源代码。是不是没有那些加载项。


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK