當前位置:編程學習大全網 - 網站源碼 - 去除加載谷歌字體解決wordpress網站加載google字體的幾種辦法

去除加載谷歌字體解決wordpress網站加載google字體的幾種辦法

第壹種方法:安裝Disable Google Font插件,但經過測試之後,沒有明顯效果。(不推薦)

第二種方法:註釋或刪除掉style.css和function.php有關加載Google字體的代碼fonts.googleapis.com即可。

第三種方法:將以下代碼添加到主題目錄下的functions.php中

如果在更改style.css或function.php文件之後,wordpress網站報錯,無法打開,或者新建文章時上傳圖片失敗。壹定是將wordpress文件的編碼保存為非ANSI編碼,用記事本打開,保存時選擇編碼ANSI替換掉原來的文件即可。

class Disable_Google_Fonts {

public function __construct() {

add_filter( 'gettext_with_context', array( $this, 'disable_open_sans' ), 888, 4 );

}

public function disable_open_sans( $translations, $text, $context, $domain ) {

if ( 'Open Sans font: on or off' == $context && 'on' == $text ) {

$translations = 'off';

}

return $translations;

}

}

$disable_google_fonts = new Disable_Google_Fonts;

不會的可以來小小WP 看看 或者留言給我

  • 上一篇:跪求發帖大師!!如何直接超鏈接復制文字到論壇?
  • 下一篇:購買的源碼,做網站,有什麽風險嗎?
  • copyright 2024編程學習大全網