How to define a minimum word count per post

Copy the function below and paste it into your functions.php file. The code will automatically raise an error if someone try to publish a post which is below the minimum allowed word count, defined on line 3.

function minWord($content){
	global $post;
        $num = 100; //set this to the minimum number of words
	$content = $post->post_content;
	if (str_word_count($content) <  $num)
	    wp_die( __('Error: your post is below the minimum word count.') );
add_action('publish_post', 'minWord');

Thanks to Pippin WIlliamson for submitting this great recipe!

Looking for WordPress hosting? Try WP Web Host. Prices starts at $5/month and you can try it for free!

How to define a minimum word c

Daily Email Newsletters

Weekly Email Newsletters

Subscribe to receive the latest design and creative business news, tutorials, and resources delivered to you via email—either daily (below) or weekly, to your computer, tablet, or mobile phone.

IMPORTANT NOTE: The newsletters and subscription confirmation email will be sent from the address Please be sure to whitelist that address in your anti-spam filters. Check your Junk Mail or Spam folder if you miss an email prior to whitelisting

Privacy and CAN-SPAM Compliance

All Pariah Burke newsletters comply with the U.S. CAN-SPAM Act. The newsletter even uses a third-party ESP to audit and ensure its compliance with CAN-SPAM. And your privacy is assured: your email address and other information will never be sold or given away.