Beginner's Guide for WordPress / Start your WordPress Blog in minutes

How to Limit Comment Length in WordPress

WordPress comments encourage discussions around your topic. However you may find that comments below a certain length or above a certain length are not very helpful. In this article, we will show you how to limit comment length in WordPress, so you can set both minimum and maximum comment length limit for your WordPress site.

Why limit comment length in WordPress?

Set Comment Length Limits in WordPress

In our experience of moderating online discussions for the past decade, we have found that most helpful comments are above 60 characters and below 5000 characters in length.

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

However when a person writes a comment above 5000 characters, its usually a rant / complaint that in most cases is not relevant to that particular article.

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

Let’s take a look at how to control comment length in WordPress.

Video Tutorial

Subscribe to WPBeginner

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

There are two methods to limit comment length in WordPress. The first method requires you to install a plugin. The second method uses a simple code snippet that you can add to your site.

Method 1: Limiting Comment Lenght Using a Plugin

First thing you need to do is install and activate Control Comment Length plugin. Upon activation, simply go to Settings » Control Comment Length to configure the plugin settings.

Controlling comment length in WordPress using a plugin

The plugin’s user interface is in German with English. You can set both minimum and maximum number of characters a comment can have. We recommend using 60 for minimum and 5000 for maximum character count.

You can also add messages that will be visible to users when there comments are either too short or too long. The plugin only provides these messages in the German language. You can replace it with your own message.

Method 2: Limit Comment Length Using Code Snippet

The second method is for users who don’t mind dealing with code code. We will add a filter hook to preprocess_comment. This filter is run before WordPress saves any comments to database or runs any other pre-processing on submitted comments. We will use it to check the comment length. If it is above or below the set comment length parameters, then we will show users an error message.

Simply add this code to your theme’s functions.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;

Comment too long error

We hope this article helped you limit comment length in WordPress. You may also want to checkout our guide on 12 vital tips and tools to combat comment spam in WordPress.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

Disclosure: Our content is reader-supported. This means if you click on some of our links, then we may earn a commission. See how WPBeginner is funded, why it matters, and how you can support us.

The Ultimate WordPress Toolkit

Get FREE access to our toolkit – a collection of WordPress related products and resources that every professional should have!

Reader Interactions

17 CommentsLeave a Reply

  1. The control comment length plugin is no longer available> Do you have any suggestions about another plugin that will do the same thing.


    • While we don’t have a recommendation at the moment, we will be sure to update this article when we find a plugin we would recommend.


  2. For your information, the “Control Comment Length” is no longer on WordPress directory. Thanks

    • Thank you for letting us know, we’ll be sure to keep an eye out for an alternative plugin :)


  3. hi,
    first thanks for your code
    and how can i stay in my page and open a popup message showing the message error ?


  4. I am thrilled to have found this! It’s life-changing in a site like mine!

    Can you give me a code to add that EXEMPTS this limit for myself (admins)? Thanks

  5. Hi,

    The plugin is no longer in WordPress directory, but the code works very well. However, I want to know is there a way we can “gray out” or “disable” the submit button if the comment length conditions are not met. Right now, what this code do is it allow the user to submit comment and they get an error message if their comment length is not as per code criteria. By greying out the button we will be able to stop users from getting irritated and their will be no need to hit the back button.

  6. hi where can i download the wordpress application?
    can you give the link?or send it thru my gmail? thanks

    • 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;

  7. Is there any way to limit comments, and if the limit is exceeded a new page will be created and the rest of the comment is on a new page?

Leave A Reply

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.