WordPress 在 2.8 版本之后,增加了几个新的 link 标签 rel 属性,例如:

  1. <link rel='index' title='Sino Blog' href='http://www.sinoblog.org' />
  2. <link rel='start' title='Hello World' href='http://www.sinoblog.org/2007/09/hello-world.html' />
  3. <link rel='prev' title='QQ邮箱支持域名邮箱个性化邮件服务' href='http://www.sinoblog.org/2009/09/qq-domainmail.html' />

如果要去掉 WordPress 博客 header 部分的这些 rel 属性,可以通过修改主题支持函数(functions.php)来实现,规则是:

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

例如,要去掉下面的这些 link 标签:

  1. <link rel="alternate" type="application/rss+xml" title="WP Engineer RSS Feed" href="http://www.aliyoga.com/yujia/feed/" />
  2. <link rel="alternate" type="application/atom+xml" title="WP Engineer Atom Feed" href="http://www.aliyoga.com/yujia/feed/atom/" />
  3. <link rel="pingback" href="http://www.aliyoga.com/yujia/xmlrpc.php" />
  4. <link rel="EditURI" type="application/rsd+xml" title="RSD" href="http://www.aliyoga.com/xmlrpc.php?rsd" />
  5. <link rel='index' title='WP Engineer' href='http://www.aliyoga.com' />
  6. <link rel='start' title='Use WordPress 2.7 Offline' href='http://www.aliyoga.com/shop/' />
  7. <link rel='prev' title='Recents Drafts All Authors' href='http://www.aliyoga.com/bbs/' />

分别对应的 remove_action 代码是:

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

在一个老外的博客看到的,记录一下 :-)

Comments are closed.