零基础建站培训介绍

当前位置:

wordpress wp_head() 作用详解

wp_head()是wordpress的一个特别重要的函数,基本上所有的主题在header.php这个文件里都会使用到这个函数。

而且很多插件为了在header上加点东西也会会到wp_head(),比如SEO插件

但是,在wp_head()出现的这个位置,会增加很多并不常用的代码,比如:

<link rel=”EditURI” type=”application/rsd+xml” title=”RSD” href=”https://www.xuewangzhan.net/xmlrpc.php?rsd” />
<link rel=”wlwmanifest” type=”application/wlwmanifest+xml” href=”https://www.xuewangzhan.net/wp-includes/wlwmanifest.xml” />
<link rel=’index’ title=’WordPress教程网’ href=’https://www.xuewangzhan.net’ />
<meta name=”generator” content=”WordPress 3.0.4″ />

这些代码并不是必须的。但是删除wp_head()并不是一个很好的选择,因为这样会影响到一些插件的使用。

那我们该怎么删除这些代码呢?

方法也很简单:

到主题的functions.php这个文件里。如果没有,则自己创建,一般正常的wordpress主题都会有。在最后加上这一段:

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
上一课: 下一课:

发表评论

邮箱地址不会被公开。 必填项已用*标注

相关教程

  • wp_head()是wordpress的一个特别重要的函数,基本上所有的主题在header.php这个文件里都会使用到这个函数。而且很多插件为了在header上加点东西也
  • 制作手机版网站的时候,除了页面简洁、操作方便等访问者可以看到的地方以外,就是 Meta 标签的设置,合理设置 Meta 标签 对手机版网站的搜索引擎优化
  • *{margin: 0; padding: 0}的作用*{margin: 0; padding: 0}作用是Reset(重置)浏览器默认样式,对于各浏览器样式统一的话有着简单粗暴的效果。