wordpress打开速度慢最佳解决方案

1、去掉google字体加载,这里推荐用插件:Disable Google Fonts

 

2、去掉head头部  s.w.org url链接,在主题的function.php 加入以下代码

add_filter( 'wp_resource_hints', 'remove_dns_prefetch', 10, 2 );

function remove_dns_prefetch( $hints, $relation_type ) {
if ( 'dns-prefetch' === $relation_type ) {
return array_diff( wp_dependencies_unique_hosts(), $hints );
}
return $hints;
}

 

3、去掉加载表情包,代码如下:

remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
remove_action( 'wp_print_styles', 'print_emoji_styles' );
add_filter( 'emoji_svg_url', '__return_false' );

 

4、去掉http头请求信息:(禁用rest api方法)如下:

Link:<http://localhost/wordpress/wp-json/>; rel="https://api.w.org/"

 

方法一:博主推荐用一个插件:Disable REST API

 

方法 二:主题function.php加入以下代码:

add_filter('rest_enabled', '__return_false');
add_filter('rest_jsonp_enabled', '__return_false');
remove_action( 'wp_head', 'rest_output_link_wp_head', 10 );
remove_action( 'wp_head', 'wp_oembed_add_discovery_links', 10 );

 

5、去掉其它无用的信息,都是加入主题function.php文件里的。代码如下:

remove_action( 'wp_head', 'feed_links_extra', 3 ); //去除评论feed
remove_action( 'wp_head', 'feed_links', 2 ); //去除文章feed
remove_action( 'wp_head', 'rsd_link' ); //针对Blog的远程离线编辑器接口
remove_action( 'wp_head', 'wlwmanifest_link' ); //Windows Live Writer接口
remove_action( 'wp_head', 'index_rel_link' ); //移除当前页面的索引
remove_action( 'wp_head', 'parent_post_rel_link', 10, 0 ); //移除后面文章的url
remove_action( 'wp_head', 'start_post_rel_link', 10, 0 ); //移除最开始文章的url
remove_action( 'wp_head', 'wp_shortlink_wp_head', 10, 0 );//自动生成的短链接
remove_action( 'wp_head', 'adjacent_posts_rel_link', 10, 0 ); ///移除相邻文章的url
remove_action( 'wp_head', 'wp_generator' ); // 移除版本号

 

6、wordpress 数据库连接地址问题

我们都知道,我们wordpress程序在安装的时候,都需要写数据库地址,默认的是localhost; 有一些服务商,填写localhost会造成数据库连接不上。这样就必须填写127.0.0.1;如果还连接不上再填写你的服务器真实IP;(因为有一些服务商连接数据库填写真实的ip地址,会造成网站等待时间过长!)

wordpress打开速度慢

    A+
发布日期:2016年12月04日 13:39:00  所属分类:WordPress
最后更新时间:2024-03-16 11:45:33
付杰
  • ¥ 159.0元
  • 市场价:499.0元
  • ¥ 119.0元
  • 市场价:199.0元
  • ¥ 199.0元
  • 市场价:199.0元
  • ¥ 398.0元
  • 市场价:498.0元

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: