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编辑器中增加链接性能主动退出nofollow的办法

由于偶然加一些站外链接,普通都是nofollow,独自写入很费事,所以揣摩从编辑器动手,经过这个插件(http:/...

WordPress改换主域名后需求的操作分享

博客改换主域名是很失常的事件,但改换完主域名之后,有一些事件是必需实现,否则会影响到你的WordPress博客...

Wordpress罕用插件以及插件罕用代码

要害字形容:罕用 插件 代码 以及 &mdash 文章 即可 &nbsp 而后 统计   这篇文章是我之前为一个香港人...

wordpress增加更新数据库等操作提醒报错

很长工夫没有动过wordpress里的规划了,进过许久策动,明天决议扭转一下规划了。然而郁闷的事件随之而来,当...

WordPress完成黑白标签云的办法

本文实例讲述了WordPress完成黑白标签云的办法。分享给大家供大家参考。详细剖析如下: 黑白标签云咱们在很...

制止wordpress主动将半角转换为全角 制止全角和半角的转换

找到wp-includes/formatting.php文件中复制代码代码如下:// This is not a tag, nor is the texturization ...

需求提交

客服服务

亿鸽在线客服系统