最近很多朋友都在問為什麼 wordpress 的打開速度非常慢,有時候需要 10 幾秒鐘才能打開,很多人都想解決這個問題,但是又不知道該如何下手,其實解決這個問題非常簡單,因為 wordpress 默認是會加載 google 字體的,而且 google 眾所周知的,在國內會被牆,所以拖慢了你網站或博客的打開速度,下面,我們就這個問題提供三種解決方法:

方法一:安裝插件 Disable Google Fonts 或 Remove Open Sans font Link from WP core 等相關插件後啓用插件即可,安裝方法可直接在你的 wordpress 管理後台安裝插件中搜索插件名直接安裝即可!半夏推薦各位使用這種方法,簡單,快捷,不會受 wordpress 升級或切換主題等問題的影響。

方法二:代碼到當前所用的主題的 functions.php 中即可,代碼如下:

/** * WordPress 後台禁用 Google Open Sans 字體,加速網站 * http://www.wpdaxue.com/disable-google-fonts.html */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;}

或者使用如下代碼也可:

wp_deregister_style(‘open-sans’);

wp_register_style(‘open-sans’,false);

wp_enqueue_style(‘open-sans’,”);

}

add_action(‘init’,’remove_open_sans’);

方法三:Google Fonts 換為 360CDN,在當前的主題文件中添加如下代碼即可,代碼如下:

<?php/* Plugin Name: DW Replace Open Sans Plugin URI: http://devework.com/replace-open-sans.html Description: 將 WordPress 後台中的 open-sans 字體加載源從 Google Fonts 替換為 360 的 CDN 加載源。 Author: Jeff Author URI: http://devework.com/ Version: 1.0 Text Domain: dw-replace-open-sans */ function devework_replace_open_sans() { wp_deregister_style(‘open-sans’); wp_register_style( ‘open-sans’, ‘//fonts.useso.com/css?family=Open+Sans:300italic,400italic,600italic,300,400,600’ ); wp_enqueue_style( ‘open-sans’);}add_action( ‘wp_enqueue_scripts’, ‘devework_replace_open_sans’ );add_action(‘admin_enqueue_scripts’, ‘devework_replace_open_sans’);?>

以上,自己去試試吧。