如何禁止WordPress头部加载s.w.org
WordPress在头部添加dns-prefetch,应该是为了从s.w.org预获取表情和头像,目的是提高网页加载速度 ,但s.w.org国内根本无法访问,什么预获取、什么提高速度,都是泡影,不仅没用处,反而可能会影响速度,那就禁止它。
禁止WordPress头部加载s.w.org
升级到WordPress 4.6之后,有童鞋发现头部加载了一个:
<link rel='dns-prefetch' href='//s.w.org'>
WordPress在头部添加dns-prefetch,应该是为了从s.w.org预获取表情和头像,目的是提高网页加载速度 ,但s.w.org国内根本无法访问,什么预获取、什么提高速度,都是泡影,不仅没用处,反而可能会影响速度,那就禁止它。
将下面的代码添加到主题functions.php模板中:
方法一
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 );
方法二貌似兼容性更好些。
附带一个禁止加载表情代码
// Remove emoji script remove_action( 'wp_head', 'print_emoji_detection_script', 7 ); remove_action( 'wp_print_styles', 'print_emoji_styles' ); add_filter( 'emoji_svg_url', '__return_false' );
你可能还喜欢下面这些文章

//developer.wordpress.org/rest-api/using-the-rest-api/frequently-asked-questions/#can-i-disable-the-rest-接口据此,Wordpress。

remove_meta_box( ‘dashboard_right_now’, ‘dashboard’, ‘normal’ );add_action( ‘admin_init’, ‘remove_dashboard_meta’ );

有很多主题会用到id信息,但是查看id的方式有些麻烦,这里提供一个代码来查看id。 add_filter(“manage_${taxonomy}_custom_column”, ‘ssid_return_value’, 10, 3);

add_filter(‘allow_password_reset’, ‘__return_false’ );如果仅仅是禁止某些特定的用户使用这个功能,可以在主题的 functions.php 添加下面的代码:

通过下面的JS代码,可以有效地防止别人直接***拷贝你的文章,用frame标签引用你的文章时,会自动跳转到文章正常链接,同时禁止右键菜单。打开当前主题头部模板header.php找到:<

remove_meta_box( ‘dashboard_right_now’, ‘dashboard’, ‘normal’ );add_action( ‘admin_init’, ‘remove_dashboard_meta’ );

原创内容经常被别人轻易***转载?站长工具箱中自带内容保护插件,可禁止右键和***功能,使用十分方便。登录WordPress后台,依次点击【外观】-【编辑】,找到footer.php并编辑,在<