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装置应用Flowplayer繁难指南

本文是简略易懂的古代魔法系列文章的第二弹~ 一、Flowplayer简介 FlowPlayer 是一个用Flash开发的在Web上的...

WordPress上传图片主动重命名的办法

复制代码代码如下:add_filter( 'wp_handle_upload_prefilter', 'custom_upload_name' ); function custom...

wordpress在lighttpd下的重写规定及留意细节

wordpress博客是应用人数最多的一个开源博客顺序,动态化也是最多人像要到的成绩,关于老手来收,动态化的解...

利用Fix Rss Feeds插件修复WordPress的Feed显示谬误

明天忽然有个网友留言说博客的Feed挂了,症状如下: Chrome间接关上订阅页面显示如下: This page contain...

wordpress增加顶级菜单完成思绪

比方本人创立了一个主题,那么需求在后盾增加一些设置选项,所以就触及到了后盾增加顶级菜单的需要: 复制代...

Wordpress将选中内容分享到新浪腾讯微博的办法

本文实例讲述了Wordpress将选中内容分享到新浪腾讯微博的办法。分享给大家供大家参考。详细办法如下: 1、引...

需求提交

客服服务

亿鸽在线客服系统