禁掉的方法有两个,根据兼容性情况选择合适的一个即可。
第一个:
remove_action( ‘wp_head’, ‘wp_resource_hints’, 2 );
第二个:
function remove_dns_prefetch( $hints, $relation_type ) { if ( ‘dns-prefetch’ === $relation_type ) { return array_diff( wp_dependencies_unique_hosts(), $hints ); } return $hints; } add_filter( ‘wp_resource_hints’, ‘remove_dns_prefetch’, 10, 2 );