时间:2014-01-26所属栏目: WordPress教程 来源: 热度:
在做Wordpress主题时常常的做法就是变动一个现有的主题,好比直接变动官方提供的主题。但WP官方提供的 WordPress主题 通过 wp_head() 在页面的头部输出了许多对象,可是这些标签许多是没用的,固然这些代码也没有什么副浸染,可是若想保持一个简捷的 header 就必需“做些手脚”。
以是这篇日记将教你怎样移除 header 中的下面几个标签,你可以按照本身的需求选择移除。移除要领是将下面临应的remove_action复制到 functions.php 就能一次性移除了。
下面我们就来看看 wp_head 中都有哪些无关紧急的代码:
<link rel="EditURI" type="application/rsd+xml" title="RSD" href="http://example.com/xmlrpc.php?rsd" />
这是 XML-RPC 客户端发明机制必要用到的,假如你不知道这个是什么意思,可能没有集成相同 Flickr 这类处事到你的站点,那么你可以安详的移除它:
remove_action('wp_head', 'rsd_link');
<link rel="wlwmanifest" type="application/wlwmanifest+xml" href="http://example.com/wp-includes/wlwmanifest.xml" />
假如你没有行使 Windows Live Writer 来写日记,那就移除它吧:
remove_action('wp_head', 'wlwmanifest_link');
它是用来在 header 表现你的 WordPress 版本号:
<meta name="generator" content="WordPress 3.5.1" />
你本身虽然知道你所行使的 WordPress 版本了,而且给暴徒知道,还能造成安详裂痕:
remove_action('wp_head', 'wp_generator');
Post relational links(和日记相干的 Link)即下面这一堆:
<link rel='index' title='Main Page' href='http://blog.wpjam.com' />
<link rel='start' title='Article in the distant past' href='http://blog.wpjam.com/hello-world/' />
<link rel='prev' title='The Post Before This One' href='http://blog.wpjam.com/post-before/' />
<link rel='next' title='The Post After This One' href='http://blog.wpjam.com/post-after/' />
一些赏识器可以通过这些代码举办导航,可是一个计划优越的主题同样可以做到,以是移除它们:
remove_action('wp_head', 'start_post_rel_link');
remove_action('wp_head', 'index_rel_link');
remove_action('wp_head', 'adjacent_posts_rel_link');