Cleanup WordPress Header 瘦身wordpress

http://wpengineer.com/1438/wordpress-header/


Cleanup WordPress Header

WordPress implements new standard features in the head of the theme since version 2.5, that are always on the hook wp_head. Even in WordPress 2.8 new functions were added. If you don't need them you can easily disable them by using the functionremove_action.

Function remove_action

remove_action( $tag, $function_to_add, $priority, $accepted_args );

This function removes a function attached to a specified action hook. This method can be used to remove default functions attached to a specific action hook and possibly replace them with a substitute.

Important: To remove a hook, the $function_to_remove and $priority arguments must match when the hook was added. This goes for both filters and actions. No warning will be given on removal failure.
via: WP Codexy

The following syntax shows an excerpt, only a part of the output you can have in your theme. They result from the standard functions, which are loaded in the head of the theme. Visible, if you search in the file wp-includes/default-filters.php for the Hook wp_head. Not all filters should be deactivated, because in most cases they are useful. But WordPress is not only as classical blog in use and therefore some functions are not necessary.


    
    
  • <link rel="alternate" type="application/rss+xml" title="WP Engineer RSS Feed" href="http://wpengineer.com/feed/" />
  • <link rel="alternate" type="application/atom+xml" title="WP Engineer Atom Feed" href="http://wpengineer.com/feed/atom/" />
  • <link rel="pingback" href="http://wpengineer.com/blog/xmlrpc.php" />
  • <link rel="EditURI" type="application/rsd+xml" title="RSD" href="http://wpengineer.com/xmlrpc.php?rsd" />
  • <link rel='index' title='WP Engineer' href='http://wpengineer.com' />
  • <link rel='start' title='Use WordPress 2.7 Offline' href='http://wpengineer.com/use-wordpress-27-offline/' />
  • <link rel='prev' title='Recents Drafts All Authors' href='http://wpengineer.com/recents-drafts-all-authors/' />

This is an example, not a recommendation where some functions are deactivated. Check your header and turn off what you don't need. Less markup and better loading time.


    
    
  • remove_action( 'wp_head', 'feed_links_extra', 3 ); // Display the links to the extra feeds such as category feeds
  • remove_action( 'wp_head', 'feed_links', 2 ); // Display the links to the general feeds: Post and Comment Feed
  • remove_action( 'wp_head', 'rsd_link' ); // Display the link to the Really Simple Discovery service endpoint, EditURI link
  • remove_action( 'wp_head', 'wlwmanifest_link' ); // Display the link to the Windows Live Writer manifest file.
  • remove_action( 'wp_head', 'index_rel_link' ); // index link
  • remove_action( 'wp_head', 'parent_post_rel_link', 10, 0 ); // prev link
  • remove_action( 'wp_head', 'start_post_rel_link', 10, 0 ); // start link
  • remove_action( 'wp_head', 'adjacent_posts_rel_link', 10, 0 ); // Display relational links for the posts adjacent to the current post.
  • remove_action( 'wp_head', 'wp_generator' ); // Display the XHTML generator that is generated on the wp_head hook, WP version

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值