Enabling comments on your WordPress blog may be beneficial for your website. It enables your readers to publish their opinions and exchange ideas. However, a lot of readers tend to leave one word or two words comments. Obviously, these are not the type of comments you would like to get for your posts.
By default, WordPress doesn’t have a built-in mechanism te require a decent length for comments. In this post, we will explain to you how to require a minimum length in your WordPress comment form using two different methods.
Why require a minimum length for WordPress comments
If you own a comment-enabled blog maybe you have received may short comments like these: “Very nice post”, “Excellent tutorial”, “Thanks for sharing”, etc. Most of these comments do not sound natural and they give no extra value to your posts.
In fact, this type of comments is considered spam. Because in most cases they are posted so as to get backlinks from your site.
Short comments don’t really harm your blog. The only downside of it is that it doesn’t look nice when you get hundreds of comments like these. What you actually need are good feed and constructive opinions from you readers.
How to set a limit length for comments
Requiring a minimum and a maximum length for your WordPress comments is actually an easy task. You can do it either by installing a plugin or by inserting a php code snippet in your theme.
Solution 1- Require a limit comment length using a plugin
I am pretty sure that there are many plugins out there that can force users to introduce comments with a decent length. Personally, I prefer Yoast Comment Hacks because it comes with additional useful functions.
The following plugin is designed to control the maximum length of comments. It has a configurable limit on the length of comments introduced in your comment form. It also displays a character countdown in the text area and is dynamically updated while typing.
I imagine that both plugins can be installed at the same time. This is in case you Want to limit both the minimum and maximum length of comments. If you are using both plugins on the same site please tell us about your experience.
Solution 2- Require a limit comment length using php
The second solution is our favorite. For performance reasons we always do our best to cut down the number of installed plugins on our websites. If you are comfortable with editing code files then consider giving this snippet a try. All you have to do is copy the php code below and paste it in your theme´s functions.php or comments.php file.
The snippet is just a PHP function that filters the input of the comments form. When the user submits a comment It checks if this latter has the required length. If the comment is shorter o longer than what is defined in the filter it displays an error message and advises the user to make the necessary changes.
In case you are receiving a lot of short spam comments just give the snippet above. Let me know if it works for you. In case you use a different method to require a minimum or a maximum length for comments, we encourage you to share your solution with us.How to require a minimum length for your #WordPress comments form Click To Tweet