在WordPress主题里,如何去掉Google字体?

网友解答: 我已经使用wordpress建站3年多了,这个问题我也遇到过,不过比较好解决,禁用Google字体可以加快网站打开速度。最简单的一种禁用方法,就是安装插件Disable Go

网友解答:

我已经使用wordpress建站3年多了,这个问题我也遇到过,不过比较好解决,禁用Google字体可以加快网站打开速度。

最简单的一种禁用方法,就是安装插件Disable Google Fonts,然后进行禁用。进入WP后台,点击插件-安装插件-搜索Disable Google Fonts点击安装。安装后,点击启用即可完成,不需要进行其他的设置了。

第二种方法,是修改代码,以下代码添加到当前主题functions.php中。

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;

这两种方法基本就可以了,禁用谷歌字体后,网站打开速度明显变快。

标签: