wordpress優(yōu)化頭部 去掉版權(quán)等信息 wordpress去掉generator
發(fā)布時間:2012-07-30 17:06:13 作者:佚名
我要評論

一般看下就應(yīng)該明白是什么意思的。這樣可以保證html頭部不再有其它的代碼了。去掉了wordpress的generator標(biāo)簽
wordpress在默認情況下,頭部會出現(xiàn)很多平時用不到的html代碼,比如:
<link rel="alternate" type="application/rss+xml" title="RSS 2.0 - all posts" />
<link rel="alternate" type="application/rss+xml" title="RSS 2.0 - all comments" />
<link rel="pingback" />
<link rel="EditURI" type="application/rsd+xml" title="RSD" />
<link rel="wlwmanifest" type="application/wlwmanifest+xml" />
<link rel='index' title='SBM Stone Crusher Machine|Grinding Mill' />
<meta name="generator" content="WordPress 3.4" />
上面的標(biāo)簽中,比如generator,將會暴露你的博客程序用的是哪個版本,這個信息泄漏有時會對博客的安全產(chǎn)生一定的影響。同時,也并不需要用這么些標(biāo)簽。
去掉一些不用的標(biāo)簽,網(wǎng)上有方法說主題目錄下的 functions.php里增加以下代碼:
function wpbeginner_remove_version() {
return ”;
}
add_filter('the_generator', 'wpbeginner_remove_version');//wordpress的版本號
remove_action('wp_head', 'feed_links', 2);// 包含文章和評論的feed。
remove_action('wp_head', 'index_rel_link');//當(dāng)前文章的索引。
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 );
不需要的直接//注釋掉就行了。一般看下就應(yīng)該明白是什么意思的。這樣可以保證html頭部不再有其它的代碼了。去掉了wordpress的generator標(biāo)簽。
復(fù)制代碼
代碼如下:<link rel="alternate" type="application/rss+xml" title="RSS 2.0 - all posts" />
<link rel="alternate" type="application/rss+xml" title="RSS 2.0 - all comments" />
<link rel="pingback" />
<link rel="EditURI" type="application/rsd+xml" title="RSD" />
<link rel="wlwmanifest" type="application/wlwmanifest+xml" />
<link rel='index' title='SBM Stone Crusher Machine|Grinding Mill' />
<meta name="generator" content="WordPress 3.4" />
上面的標(biāo)簽中,比如generator,將會暴露你的博客程序用的是哪個版本,這個信息泄漏有時會對博客的安全產(chǎn)生一定的影響。同時,也并不需要用這么些標(biāo)簽。
去掉一些不用的標(biāo)簽,網(wǎng)上有方法說主題目錄下的 functions.php里增加以下代碼:
復(fù)制代碼
代碼如下:function wpbeginner_remove_version() {
return ”;
}
add_filter('the_generator', 'wpbeginner_remove_version');//wordpress的版本號
remove_action('wp_head', 'feed_links', 2);// 包含文章和評論的feed。
remove_action('wp_head', 'index_rel_link');//當(dāng)前文章的索引。
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多行:
復(fù)制代碼
代碼如下://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 );
不需要的直接//注釋掉就行了。一般看下就應(yīng)該明白是什么意思的。這樣可以保證html頭部不再有其它的代碼了。去掉了wordpress的generator標(biāo)簽。
相關(guān)文章
- 關(guān)鍵字描述:理由 ZBLOG 安裝 優(yōu)化 時間 WordPress 可以 文章 博客 讓我堅守ZBLOG的十二大理由: 盡管WordPress是博客程序里面的老大,它的插件最多,模2009-06-06
- 自從換了域名,換了主題以后,我一直努力令博客的瀏覽體驗更加好,但因此也掛載了大量的JS文件,頁面的載入速度一度變得非常緩慢。于是優(yōu)化就迫在眉睫了。2009-12-28
- 大家都知道頁面加載速度對博客流量有非常重要的影響。最近越來越多人也在討論頁面加載速度很可能成為谷歌和其他搜索引擎一個重要的SEO因素。2010-01-24
- wordpress毫無疑問是一個優(yōu)秀的博客系統(tǒng),其最吸引人的一個特點就是有大量的外觀主題(theme)可以滿足個性化的博客展示需求。2009-11-09
- Wordpress中根據(jù)不同的頁類型輸出對應(yīng)的title標(biāo)題的實現(xiàn)代碼,優(yōu)化標(biāo)題。2011-04-21
wordpress數(shù)據(jù)庫優(yōu)化和清理冗余數(shù)據(jù)的方法
本文主要介紹了wordpress數(shù)據(jù)庫優(yōu)化和清理冗余數(shù)據(jù)的方法,大家參考使用吧2014-02-13WordPress性能優(yōu)化加速五大方法:PHP MysqL優(yōu)化等
優(yōu)化Wordpress性能,一般我們是從這幾個方面來發(fā)力:服務(wù)器PHP腳本執(zhí)行效率、MysqL數(shù)據(jù)庫查詢性能、Wordpress評論、圖片、JS、CSS等靜態(tài)文件加載速度。如果要把Wordpress性2015-01-13