国内外主机
测评及优惠码

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.wpmee.com/xmlrpc.php?rsd” /> <link rel=”wlwmanifest” type=”application/wlwmanifest+xml” href=”https://www.wpmee.com/wp-includes/wlwmanifest.xml” /> <link rel=’index’ title=’WordPress迷’ href=’https://www.wpmee.com’ /> <meta name=”generator” content=”WordPress 4.9.8″ />

这些代码并不是必须的。但是删除wp_head()并不是一个很好的选择,因为这样会影响到一些插件的使用。
那我们该怎么删除这些代码呢?
方法也很简单:
到主题的functions.php这个文件里。如果没有,则自己创建,一般正常的WordPress主题都会有。
在最后加上这一段:

<?php 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 ?>

经测试可行。来源:
http://wordpress.org/support/topic/remove-feed-from-wp_head

赞一个
赞(0)
版权声明:本文采用知识共享 署名4.0国际许可协议 [BY-NC-SA] 进行授权
文章名称:《WordPress解析wp_head()》
文章链接:https://www.ibytx.com/1352.html
本站资源仅供个人学习交流,请于下载后24小时内删除,不允许用于商业用途,否则法律问题自行承担。

相关推荐

  • 暂无文章

登录

找回密码

注册