释放双眼,带上耳机,听听看~!
我们辛苦收集的内容免费开放下载,仅仅只需评论应该不过分吧?但是我发现很多朋友评论一两个字,特别的敷衍,就这样完全不管我的想法, 所以我就想要限制文章评论当中的最少字数。
我在百度上面搜索这么一段代码,自己也使用过,确实有效果,现在分享出来:
添加在 wordpress 主题的的 function.php 文件中
add_filter( 'preprocess_comment', 'minimal_comment_length' );
function minimal_comment_length( $commentdata ) {
$minimalCommentLength = 40;
if ( strlen( trim( $commentdata['comment_content'] ) ) $maxCommentlength) && !is_user_logged_in() ){
err('对不起,你的文采太好了,你的笑话太长了,我只要' . $maxCommentlength .'个字的笑话!(目前字数:'. $pointCommentlength .')【登录后无此限制】');
exit;
}
return $commentdata;
}
add_filter('preprocess_comment', 'lxtx_set_comments_length');
使用方法
添加在 wordpress主题的的 function.php 文件中即可
文章来源于互联网:wordpress纯代码控制文章回复/评论最少字数