Home / functions.php / Require minimum word count
  • How to Require minimum word count

    no thumbnail sorry: Require minimum word count

    Adding this code to your functions.php of your wordpress theme will require all posts to have a minimum of 100 words before they can be published.

    ( click code to copy )

    wordpress snippet : PHP

    <>
    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');
    

    ( WordPress codex functions, hooks, in this snippet. )

    publish_post, add_action, __, wp, wp_die,