Hi WP learners welcome to Lets Learn Now and in this article, I will discuss how to limit comment length in WordPress. Comments are very essential for your blog but some case it affects a bit problem for the users when it is too long.
Post Contents
Why Set Maximum Comment Length In WordPress?
Suppose, someone writes a one-word in a comment, it usually is not very helpful for the discussion. In most cases, it seems like a spam comment because the author is trying to achieve a backlink from your website.
However, when someone comments more than 5,000 characters, it’s usually a rant/complaint that in most cases is not relevant to that particular essay.
How to Limit Comment Length in WordPress
There are so many ways to set limit in your comment, but today I will show you some easy method so that you can prevent irrelevant comment and make it great for users. Well, let’s see how to limit comment length in WordPress.
Methos 1: Use The Code To Set The Maximum Limit Using Functions.PHP
Just log in to your WordPress admin panel then visit Appearance>>Editor>>functions.php file. This is a straightforward way indeed.
If you want to open your site’s Funnctions.php using cPanel of your web hosting account.
Just navigate to cPanel > file manager > wp-content > themes > theme name > functions.php file.
add_filter( ‘preprocess_comment’, ‘blogginglove_comment_limit’ );function blogginglove_comment_limit($comment) { if ( strlen( $comment[‘comment_content’] ) > 4000 ) { wp_die(‘Please keep your comment under 4000 characters. Comment is too long to accept’); } return $comment; }
Method 2: Limiting Comment Lenght by Using a Plugin Called control-comment-length:
First, install and active control-comment-length plugin. If you are having trouble installing the plugin, then you may want to see how to install a WordPress plugin
Download Greg’s Comment Length Limiter from Here
After activating this plugin, you will find it under your admin settings as Comment Length Limit
Firstly you need to do is set your upper limit and after that, you click save the changes to store your setting.
Finally, visit any of your posts in order to check the job that you recently have done with a plugin.
You may want to see How to Create a Website Using WordPress Step By Step for Beginners
I hope you learned how to limit comment length in WordPress. If this article helps you make sure you subscribe to Lets Learn Now YouTube channel to get more WordPress videos and trips in order to manage your WordPress sites. You can also find us on Twitter and Facebook.