How To Set Minimum Post Length In WordPress Posts ?

If you run a blog with many authors and you need a minimum word count for your WP posts so that other authors in your blog won’t be able to create very small posts with only links in them.

Simply open you theme’s function.php file and add this code changing < 100 with the number of minimum words you want to set in your blog posts as default:

function minWord($content)
{
global $post;
$content = $post->post_content;
if (str_word_count($content) < 100 )
wp_die( __(‘Error: your post is below the minimum word count. Expand it to minimum 100 words.’) );
}
add_action(‘publish_post’, ‘minWord’);

It will generate the following message whenever any of your blog author tries to create a post with less than 100 words:

Error: your post is below the minimum word count. Expand it to minimum 100 words.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.