禁用Google字体的方法

WordpPress打开速度慢,是谷歌字体加载速度慢造成的, Google被墙,需要加载谷歌资源,网站打开速度自然相当慢,建议不要加在谷歌资源

禁用Google字体的方法

后台禁用谷歌字体的有如下几种方法

第一种,使用插件就可以实现,这种方法最简单,Disable Google Fonts 和 Remove Open Sans font Link from WP core这两个插件任意选择一个安装即可。

第二种,在function.php中添加下面的代码:

来自知更鸟博客

/**
 *禁用Google字体
 */
function coolwp_remove_open_sans_from_wp_core() {
wp_deregister_style( 'open-sans' );
wp_register_style( 'open-sans', false );
wp_enqueue_style('open-sans','');
}
add_action( 'init', 'coolwp_remove_open_sans_from_wp_core' );

或者

WordPress大学的方法

/**
 *禁用Google字体
 */
add_filter( ‘gettext_with_context’, ‘wpdx_disable_open_sans’, 888, 4 );
function wpdx_disable_open_sans( $translations, $text, $context, $domain ) {
if ( ‘Open Sans font: on or off’ == $context && ‘on’ == $text ) {
$translations = ‘off';
}
return $translations;
}

我用第一种代码时后台出现了

waring

所以采用了第二种代码的方法。

发表评论

游客欢迎您123

“禁用Google字体的方法” 有 1条评论

  1. 请问怎样才能禁用来自fonts.gstatic.com的谷歌字体?用了文章里的两个插件都不管用,我的网站还没有进行任何设计大小就已经达到了5MB了,真的是头疼