If you’re running a WordPress blog with multiple authors, then it’s important for you to maintain your blog’s content quality. With WordPress, you can restrict your authors to publish a post without having enough content.
Here is a code snippet that lets you set a minimum word count for your WordPress posts. You can paste this code snippet in your theme’s functions.php file. But don’t forget to change minimum word count as per your need.
This code snippet will check how many words a post has and if it contains less than 500 words, then WordPress will not allow this post to publish.
// set minimum word count to publish post
function wcs_min_word_count( $content ) {
global $post;
$wordcount = 500;
$content = $post->post_content;
if ( str_word_count( $content ) < $wordcount )
wp_die( __( 'Error: your post is below the minimum word count. Posts must have at least ' . $wordcount . ' words.' ) );
}
add_action( 'publish_post', 'wcs_min_word_count' );