level 7
通过观察代码可以看到,WP是这样加载字体的,在script-loader.php(wp-3.9)的580行代码进行加载。
functions.php过滤
在主题中的functions.php文件末尾加上一下代码之一即可
// Remove Open Sans that WP adds from frontend
if (!function_exists('remove_wp_open_sans')) :
function remove_wp_open_sans() {
wp_deregister_style( 'open-sans' );
wp_register_style( 'open-sans', false );
}
add_action('wp_enqueue_scripts', 'remove_wp_open_sans');
// Uncomment below to remove from admin
// add_action('admin_enqueue_scripts', 'remove_wp_open_sans');
endif;
2014年06月02日 03点06分
1
level 11
最近发现了后台的确加载Google的字体,但是前台不会。对用户应该没多大影响
2014年06月02日 04点06分
2
前台不会加载?这是什么意思,意思是别人打开网页不会加载google字体吗?
2014年06月05日 06点06分
回复 Eden_Chen24 :是的,用户访问网站是不会加载的,可从源码中看出。
2014年06月05日 08点06分
前台主题没添加谷歌字体能出现加载问题么?有些人用的是国外主题很多都带有谷歌字体
2014年06月13日 01点06分
level 12
ok
中国联通 官方提示
⚠更改连接
━━━━━━━━━━━━━━━━━━━━━
联通网络联不通,是否尝试连
接无线网络?
—————————————————
✗ 取消 │ ✓ 确定
2014年06月02日 04点06分
4
level 9
我也是昨天才,注意到。之前一直在忙 后来还跟几个吧友提到这个事。支持!
有需要的赶紧解决一下。
2014年06月02日 14点06分
6
level 9
如果楼主的写法没能解决,可以这样写。你要是写在 ?> 后面,大巴掌伺候。
//禁用Open Sans
function remove_open_sans() {
wp_deregister_style( 'open-sans' );
wp_register_style( 'open-sans', false );
wp_enqueue_style('open-sans', '');
}
add_action( 'init', 'remove_open_sans' );
2014年06月02日 14点06分
8
函数模板 functions.php 放在最下面吧
2014年06月02日 14点06分
level 1
这两天我在本地测试前页打开也超慢,原来是这个原因?
2014年06月03日 04点06分
9
level 1
安装插件Disable Google Fonts插件就OK了
2014年06月03日 11点06分
11
真的有效 感谢分享
2014年06月05日 14点06分
回复 821042639 :昨天看到360说提供免费字体加速服务,你把wp-includes/script-loader.php文件中的fonts.googleapis.com替换为fonts.useso.com,就可以继续使用google字体了
2014年06月05日 14点06分
回复 yangstuff :试过了 没用 改了之后 还会加载Google字体的
2014年06月05日 15点06分
回复 yangstuff :亲测有用,感谢分享
2014年06月24日 05点06分
level 1
加了不管用,后台倒是很快了,前台依然那么慢,满的要死,我是再本地做的
2014年06月08日 12点06分
12
level 13
在function.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;
2014年06月22日 09点06分
14
加了之后无法打开网页
2014年06月27日 02点06分
回复 zjnx :在主题文件中的functions.php里修改 而不是系统的functions
2014年07月31日 07点07分
level 13
需要注意的是,并不是所有的主题这么操作都可以,我用的一个主题这么做就没有用,不过解决起来并不麻烦。
在function.php中搜索google字体的域名fonts.googleapis.com 或许就能找到相关的代码,注释掉就可以了。
2014年06月23日 07点06分
15
此答案 甚屌!简单实用
2014年12月09日 05点12分
level 11
不用这么麻烦,直接装个几十Kb的小插件就可以完美解决
2014年06月27日 09点06分
16
level 4
我在前面写了几个字. 禁止谷歌字体// Remove Open Sans that WP adds from frontend
if (!function_exists('remove_wp_open_sans')) :
function remove_wp_open_sans() {
wp_deregister_style( 'open-sans' );
wp_register_style( 'open-sans', false );
}
add_action('wp_enqueue_scripts', 'remove_wp_open_sans');
// Uncomment below to remove from admin
// add_action('admin_enqueue_scripts', 'remove_wp_open_sans');
endif;
现在登录显示。 建立数据库连接时出错 咋办
2015年01月21日 06点01分
21