Friday, November 27, 2020
Home Blogging How to Limit Comment Length in WordPress

How to Limit Comment Length in WordPress

WordPress feedback encourage discussions round your subject. Nevertheless you might discover that feedback under a sure size or above a sure size usually are not very useful. On this article, we’ll present you the way to restrict comment size in WordPress, so you may set each minimal and most comment size restrict in your WordPress web site.

Why restrict Comment size in WordPress?

In our expertise of moderating on-line discussions for the previous decade, we’ve got discovered that the majority useful feedback are above 60 characters and under 5000 characters in size.

When an individual writes a one-word comment, it normally is just not very useful. Generally, it’s spam as a result of the writer is solely attempting to earn a backlink out of your web site.

Nevertheless when an individual writes a comment above 5000 characters, its normally a rant / criticism that usually is just not related to that individual article.

By setting comment size limits in WordPress, you may enhance the standard of your feedback.

Let’s check out the way to management comment size in WordPress.

There are two strategies to restrict comment size in WordPress. The primary methodology requires you to put in a plugin. The second methodology makes use of a easy code snippet that you may add to your web site.

Methodology 1: Limiting Comment Length Utilizing a Plugin

Very first thing it is advisable do is set up and activate Management comment Size plugin. Upon activation, merely go to Settings » Management Comments Size to configure the plugin settings.

The plugin’s person interface is in German with English. You possibly can set each minimal and most variety of characters a comment can have. We suggest utilizing 60 for minimal and 5000 for max character depend.

You may also add messages that might be seen to customers when there feedback are both too quick or too lengthy. The plugin solely gives these messages within the German language. You possibly can exchange it with your individual message.

Methodology 2: Restrict Comments  Size Utilizing Code Snippet

The second methodology is for customers who don’t thoughts coping with code code. We are going to add a filter hook to preprocess_comment. This filter is run earlier than WordPress saves any feedback to database or runs some other pre-processing on submitted feedback. We are going to use it to test the comment size. Whether it is above or under the set comments size parameters, then we’ll present customers an error message.

Merely add this code to your theme’s capabilities.php file or a site-specific plugin.

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


You May Also Like : How to Add the New Facebook Page Plugin in WordPress

We hope this text helped you restrict comment size in WordPress. You might also need to checkout our information on 12 very important suggestions and instruments to fight comment spam in WordPress.

If you liked this article, make sure to hit the bell for getting our latest updates and share this article with your friends in every social media platforms.



Please enter your comment!
Please enter your name here

- Advertisment -

Most Popular

Post Matric & Pre-Matric Scholarship Scheme – How to Apply

Scholarship is an effective way to finance your training. If your child is vivid and anticipated to have a promising profession forward then you...

How to Earn Money from Google Online Jobs

  I can swear… Google on-line jobs comes on the highest of my listing for real on-line jobs. I've been getting cash from Google from the final...

List of Different MBA Courses in India

Master of Business Administration, generally known as MBA, is one of probably the most coveted and prestigious academic {qualifications} in India. Earlier, most MBA...

Everything You Should Know About Salary Slip / Pay Slip

Salary slip, also referred to as pay slip, is given to each worker of corporations small and enormous. Some employers challenge the pay slip...

Recent Comments