Set minimum word count for posts
This snippet defines a minimum word count for new posts. If a post does not meet the requirements the author is not able to publish it. It can also be applied to post_excerpt or post_title
/** * Snippet Name: Set minimum word count for posts * Snippet URL: https://wpcustoms.net/snippets/set-minimum-word-count-posts/ */ function wpc_minimum_wordcount($content){ global $post; $num = 200; //set this to the minimum number of words $content = $post->post_content; if (str_word_count($content) < $num) wp_die( __('Error: Please write at least 200 words.') ); } add_action('publish_post', 'wpc_minimum_wordcount');