Most blog commenters comment only for building good backlinks from your website and hence result is you get most of the comments as ‘Nice post’, ‘Great post, ‘Thanks for writing up’, ‘Thank you for the post’ etc.
In this tutorial we will be showing you how to set minimum comment text limit to encourage quality comments and increases value of your articles.
What you have to do is change the value of $minimalCommentLength string to the minimum number of characters you want to see in each comment.
Start by logging in to your WordPress site, then navigate to your admin area dashboard Appearance -> Editor and from the right dropdown menu select the theme active on your website.
Now select functions.php file for editing and paste the following code (replacing 20 with your minimal comment length):
add_filter( ‘preprocess_comment’, ‘minimal_comment_length’ );
function minimal_comment_length( $commentdata ) {
$minimalCommentLength = 20;
if ( strlen( trim( $commentdata[‘comment_content’] ) ) < $minimalCommentLength )
{
wp_die( ‘All comments must be at least ‘ . $minimalCommentLength . ‘ characters long.’ );
}
return $commentdata;
}
Alternative Method: Using A Plugin
Alternatively, if you don’t like editing you theme files (in order to continue future theme updates) then you may use a plugin like Control Comment Length. Install and activate it, after activation visit your admin area dashboard Settings -> Control Comment Length page and set the minimum number of letters.
Or if you need something more simple then you go for Minimum Comment Length plugin.
Although it hasn’t been updated in over 2 years but still it works fine. Install and activate it, after activation visit your admin area dashboard Settings -> Min Comment Length page and type in minimum comment length & the custom error message.