wp_head()是wordpress的一个非常重要的函数,
基本上所有的主题在header.php这个文件里都会使用到这个函数,
而且很多插件为了在header上加点东西也会会到wp_head(),比如SEO的相关插件。
但是,在wp_head()出现的这个位置,会增加很多并不常用的代码
这些代码并不是必须的。但是删除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
?>
2、wordpress静态化后wp-postviews不能统计阅读次数的问题
wordpress使用静态插件后,发现WP-PostView虽可以显示浏览数,但浏览数不能更新,解决办法:
wp-postviews.php这个文件
找到代码
if(defined(’WP_CACHE’) && WP_CACHE)
替换为
if((defined(’WP_CACHE’) && WP_CACHE) || (defined(’COSMETA’) && COSMETA))
没有评论,留下你的印记,证明你来过。
◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。