How to define a minimum word count per post in WordPress

WordPress: Setting minimum word count for posts

Do you want to specify a minimum word count for posts on your WordPress website or blog? Defining a minimum word count for posts should come handy for multi-author blogs that accept guest posts. Your authors will be forced to submit a post with the minimum number of words.

Copy the code below and paste it in the ‘functions.php’ file of your WordPress theme. If someone tries to publish a post that is below the minimum word count, an error message will be shown using the wp_die() function.

function minimumWords($content){
	global $post;
        $wordcount = 100; //set this to the minimum number of words
	$content = $post->post_content;
	if (str_word_count($content) <  $wordcount)
		wp_die( __('Error: your post is too short. Please increase the word count to'. $wordcount. 'words.') ); ?>
}
add_action('publish_post', 'minimumWords');