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博客SEO愈加完满的6个技巧

wordpress是十分不错的博客顺序,也是很多博客喜好者所喜爱的建站顺序之一,wordpress不只仅模版丰厚,而且...

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

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

WordPress中is_singular()函数简介

函数is_singular()检测后果为true,当上面其一前往true时:is_single()、is_page()、is_attachment()。 假如...

WordPress小工具制造办法【左近期评论工具制造】

本文实例讲述了WordPress小工具制造办法。分享给大家供大家参考,详细如下: WordPress是一个领有着无可比拟...

能无效改善WordPress CMS性能的8个插件分享

NextGen Gallery 最好的图片相册插件。弱小的支持,稳固,更新频繁,收费。WP内置的相册性能也是OK的,不过...

WordPress重复呈现需求晋级数据库的处理办法

WordPress呈现&ldquo;需求晋级数据库&rdquo;普通是网站搬家,或许WordPress版本晋级会呈现。普通状况呈现的...

需求提交

客服服务

亿鸽在线客服系统