WordPress comments encourage discussions about your theme. However, you may find that comments below a certain length or above a certain length are not very useful. In this article, we will show you how to limit comment length in WordPress, so you can set the minimum and maximum comment limit for your WordPress site.
In our experience of moderating online discussions over the past decade, we've found that the most useful comments are longer than 60 characters and less than 5,000 characters in length.
When a person writes a one-word comment, it's usually not very helpful. In most cases, it's spam because the author is simply trying to get a backlink from his site.
However, when a person writes a comment of more than 5000 characters, it is usually a complaint or 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 the length of comments 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 you to install a plugin. The second method uses a simple code snippet that you can add to your site.
The first thing you need to do is install and activate the Control Comment Length plugin. Upon activation, simply go to Settings »Comment length control to configure the plugin settings.
The plugin user interface is in German with English. You can set the minimum and maximum number of characters a comment can have. We recommend using 60 for the minimum and 5000 for the maximum character count.
You can also add messages that will be visible to users when comments are too short or too long. The plugin only provides these messages in the German language. You can replace it with your own message.
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 the database or runs any other pre-processing on submitted comments. We will use it to check the length of the comment. If it is over or under the parameters set for the comment length, 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 ('El comentario es demasiado largo. Por favor, mantenga su comentario en 5000 caracteres.'); if (strlen ($ comment ['comment_content']) < 60 ) wp_die('Comment is too short. Please use at least 60 characters.'); return $comment;
We hope this article has helped you to limit the length of comments in WordPress. You can also check out our guide on 12 Vital Tips and Tools to Fight WordPress Comment Spam.
If you enjoyed this article, please subscribe to our WordPress YouTube Channel video tutorials. You can also find us on Twitter and Facebook.