wordpress优化头部 去掉版权等信息 wordpress去掉generator

wordpress在默许状况下,头部会呈现很多平常用不到的html代码,比方:
 
<link rel="alternate" type="application/rss+xml" title="RSS 2.0 - all posts" href="http://blog.jb51.net/feed" />
<link rel="alternate" type="application/rss+xml" title="RSS 2.0 - all comments" href="http://blog.jb51.net/comments/feed" />
<link rel="pingback" href="http://blog.jb51.net/xmlrpc.php" />
<link rel="EditURI" type="application/rsd+xml" title="RSD" href="http://blog.jb51.net/xmlrpc.php?rsd" />
<link rel="wlwmanifest" type="application/wlwmanifest+xml" href="http://blog.jb51.net/wp-includes/wlwmanifest.xml" />
<link rel='index' title='SBM Stone Crusher Machine|Grinding Mill' href='http://blog.jb51.net' />
<meta name="generator" content="WordPress 3.4" />

下面的标签中,比方generator,将会暴露你的博客顺序用的是哪个版本,这个信息泄漏有时会对博客的平安产生肯定的影响。同时,也并不需求用这么些标签。
去掉一些不必的标签,网上无方法说主标题录下的 functions.php里添加以下代码:
 
function wpbeginner_remove_version() {
return &rdquo;;
}
add_filter('the_generator', 'wpbeginner_remove_version');//wordpress的版本号
remove_action('wp_head', 'feed_links', 2);// 蕴含文章和评论的feed。
remove_action('wp_head', 'index_rel_link');//以后文章的索引。
remove_action('wp_head', 'wlwmanifest_link'); // 内部编辑器如windows live writer必需。
remove_action('wp_head', 'feed_links_extra', 3);// 额定的feed,例如category, tag页。
remove_action('wp_head', 'start_post_rel_link', 10, 0);// 开端篇
remove_action('wp_head', 'parent_post_rel_link', 10, 0);// 父篇
remove_action('wp_head', 'adjacent_posts_rel_link', 10, 0); // 上、下篇.

测试了下,能够去掉wordpress的generator,有些代码还是去不掉,但还有另个一个更间接的办法。
就是在wodpress目录下修正wp-includes目录下的default-filters.php,大略在180多行:
 
//add_action( 'wp_head', 'feed_links', 2 );
//add_action( 'wp_head', 'feed_links_extra', 3 );
//add_action( 'wp_head', 'rsd_link' );
//add_action( 'wp_head', 'wlwmanifest_link' );
//add_action( 'wp_head', 'index_rel_link' );
//add_action( 'wp_head', 'parent_post_rel_link', 10, 0 );
//add_action( 'wp_head', 'start_post_rel_link', 10, 0 );
//add_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0 );
add_action( 'wp_head', 'locale_stylesheet' );
add_action( 'publish_future_post', 'check_and_publish_future_post', 10, 1 );
add_action( 'wp_head', 'noindex', 1 );
add_action( 'wp_head', 'wp_print_styles', 8 );
add_action( 'wp_head', 'wp_print_head_scripts', 9 );
//add_action( 'wp_head', 'wp_generator' );
//add_action( 'wp_head', 'rel_canonical' );
add_action( 'wp_footer', 'wp_print_footer_scripts' );
//add_action( 'wp_head', 'wp_shortlink_wp_head', 10, 0 );
add_action( 'template_redirect', 'wp_shortlink_header', 11, 0 );

不需求的间接//正文掉就行了。普通看下就应该明确是什么意思的。这样能够保障html头部不再有其它的代码了。去掉了wordpress的generator标签。

以上就是安达网络工作室关于《wordpress优化头部 去掉版权等信息 wordpress去掉generator》的一些看法。更多内容请查看本栏目更多内容!

本文相关话题: 优化头部 去掉版权 WordPress
版权声明:本文为 安达网络工作室 转载文章,如有侵权请联系我们及时删除。
相关文章
在WordPress中应用wp_count_posts函数来统计文章数量

做一个全站统计是不是很酷?短暂的博客越来越少,何不给本人的一个统计,看看本人在这个博客上致力了多少,...

wordpress完成用户历史浏览记载性能分享

COOKIE记载SESSION记载数据库记载缓存文件记载从技术难度上,第1、2种办法最简略,因而,下文将完成以COOKI...

免插件在wordpress中拔出表格的办法

WordPress 很弱小,然而其编辑器却很粗陋,可能 WordPress 依仗着本人有丰厚的插件性能所以将后盾的编辑器简...

简略理解将WordPress中的工具栏移到底部的小技巧

从 WordPress 3.1 开端引入了工具栏的概念,当用户登录后在前台和后盾的页面顶部会显示一个黑色的工具栏,经...

保障WordPress平安的完成办法

小洞不补大洞享乐。关于bloggers来说这是永恒的真谛,仅仅花一点工夫在马上就晋级上省下了很多之后修复一些...

开发者应该注意的WordPress2.9新性能小结

1.文章缩略图(Post Thumbnails) WordPress 2.9 一个比拟重头的新性能就是提供了不需求自定义字段的文章缩略...

需求提交

客服服务

亿鸽在线客服系统