现在写这个,不是为了告诉别人,因为现在这方面的教程已经很多的了,只是当作一个笔记,在换主题的时候可以比较方便的找到。
wordpress访问变慢原因在于谷歌太多的服务被挡住了的,谷歌字体也在其中,而wordpress很多主题没有修改的话都会调用这个字体,所以加载的那叫一个慢呀。
我也试过了几种方法,有更改字体为360字体库的,对于这一种方法,不知道是我这边网络还是怎么的,还是可以看到要加载很长的时间,有的时候基本和加载google的差不多的了。所以在这,我不怎么喜欢用这样的方法。
还有就是修改主题的functions函数代码,也是很简单的。网上有的说有些代码不管用,我试过两种代码,还都是可以的。
代码1
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; 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' );
代码2
//谷歌字体移除 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' );
其实代码2也只是代码1中的一部分,不过使用过一个主题,也完全没有问题,所以就给列了出来。
发表回复