How to Limit Comment Length in WordPress

Get real time updates directly on you device, subscribe now.

WordPress comments encourage discussions about your topic. However, comments below a certain length or above a certain length may not be very useful. In this article, we’ll show you how to limit the length of comments in WordPress so that you can set both the minimum and maximum comment length limits for your WordPress site.

Why limit the length of comments in WordPress?

In our experience with moderating online discussions over the past decade, we have found that most useful comments are above 60 characters and less than 5000 characters long.

When a person writes a one-word comment, this is usually not very useful. In most cases, it is spam because the author simply tries to earn a backlink from your site.

However, when someone writes a comment above 5000 characters, this is usually a complaint/complaint that in most cases is not relevant to that specific article.

By setting the limits for comment lengths in WordPress, you can improve the quality of your comments.

Let’s see how you can manage the reaction length in WordPress.

If you don’t like the video or need more instructions, continue reading.

There are two methods to limit the length of comments in WordPress. The first method requires that you install a plug-in. The second method uses a simple code snippet that you can add to your site.

Method 1: Restrict Comment Comment using a plug-in

The first thing you need to do is install the  Control Comment Length plugin and activate it. Upon activation, simply go to  Settings »Check Comment Length to configure the plug-in settings.

The user interface of the plug-in is in German with English. You can set both the minimum and a maximum number of characters that a comment can have. We recommend using 60 for minimum and 5000 for a maximum number of characters.

You can also add messages that are visible to users when their responses are too short or too long. The plug-in offers these messages only in the German language. You can replace it with your own message.

Method 2: Limit comment length using the code snippet

The second method is for users who don’t mind working with code. We will add a filter hook to  preprocess_comment. This filter is run before WordPress stores any comments in the database or performs another preprocessing on submitted comments. We use it to check the length of the comment. If it is above or below the set reaction length parameters, we will show users an error message.

Add this code to the  function.php  file of your theme or a  site-specific plug-in.

We hope this article has helped you to limit the length of comments in WordPress. You can also consult our guide on 12 important tips and tools to prevent spam in WordPress.

If you liked this article, sign up for our YouTube video tutorials about WordPress. You can also find us on Twitter and Facebook.

Get real time updates directly on you device, subscribe now.

Leave A Reply

Your email address will not be published.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More