How to Limit WordPress Comment Length for Betterment

Commenting option is a crucial factor for your WordPress site. When you run a website or blog in WordPress, you will get comment option by default. Commenting is the only way that readers can directly connect with you. They ask you questions and you will answer them. They put their views by commenting. Commenting is a factor to justify your products. Comment length is a factor for us. We can limit comment length in WordPress. Here I will show you how to limit WordPress comment length?

How to Disable Comments WordPress Site

The bloggers or websites owners always welcome comments on their posts and pages. But all the comments are not perfect. Some comments will consider as spamming. We know spam comments are really bad for our sites. Comment length can indicate the quality of that comment.

How to Allow Attachments in WordPress Comments Section

Some comments are really small below the certain length and some comments are really big above the perfect length. Most of the time these two types of comments will reject by the bloggers. So you need to maintain the perfect length of the comments. If you know how to limit WordPress comment length then you can easily do it.

Add Disqus Comments System in WordPress Site

One word or two words comments are not helpful and the comments above the certain limit are not relevant. You can limit comment length in WordPress so that no one can comment below or above the perfect length. So you need to know how to limit WordPress comment length? We see that comments are helpful which have above 60 characters and below 5000 characters.

How to Limit WordPress Comment Length

You can follow two ways to limit comment length in WordPress site. There are different plugins and using the code snippet to your site. Here I will show both ways, you can use any method.

How to limit WordPress comment length: Using Plugin

Go to WordPress dashboard. Tap on Plugins >> Add New. Then install and activate Greg’s Comment Length Limiter plugin.

After activating this plugin. Go to Settings >> Comment Length Limiter to configure this plugin.

How to limit WordPress comment length

Now you can see the configuration page. Here you can different settings that you can modify as you wish.

After doing all the settings click on Save Changes. You can fixed maximum limit with this plugin. If you want to set minimum limit then you need to use another plugin.

Install and activate Minimum Comment Length plugin. Now go to Settings >> Minimum Comment Limit. Set the minimum comment length. Here you can enter the error messages that will display when someone tries to write comments below the minimum limit.

How to limit WordPress comment length

How to limit WordPress comment length: Using Code

There is another way to limit comment length in WordPress. You need to add code.

Navigate to function.php file from your WordPress Dashboard

Now copy the below code and paste the code into your theme’s function.php file.

add_filter( 'preprocess_comment', 'wpb_preprocess_comment' );
function wpb_preprocess_comment($comment) {
if ( strlen( $comment['comment_content'] ) > 5000 ) {
wp_die('Please keep your comment under 5000 characters.');
}
if ( strlen( $comment['comment_content'] ) < 60 ) {
wp_die('Please use at least 60 characters for your comment.');
}
return $comment;
}

You can change the value 5000 and 60 to change the maximum and minimum limitation.

That’s all. You have done.

Munna Hossain
 

Hello, I am Munna Hossain. I am a professional blogger and affiliate marketer. I am interested in technology, blogging, SEO, and WordPress. My blog Mytechgoal provides you all information about technology, blogging, SEO, and affiliate marketing.

Click Here to Leave a Comment Below 0 comments