WordPress升级到4.9.6之后,新增了一个功能,评论处出现一个勾选框,确认是否存储Cookie信息的隐私选项,如果使用自带的comment_form函数则会直接输出这个勾选框,如果不想使用这个功能,可以使用官方钩子函数去掉。
移除评论隐私Cookie确认存储勾选框,前台不显示,在你所使用的WordPress主题的functions.php中增加如下代码:
[php]add_filter('comment_form_field_cookies','__return_false');[/php]
要默认支持记录评论者的Cookie,则增加这段代码:
add_action('set_comment_cookies','coffin_set_cookies',10,3);
functioncoffin_set_cookies($comment,$user,$cookies_consent){
$cookies_consent=true;
wp_set_comment_cookies($comment,$user,$cookies_consent);
}