As a seasoned WordPress developer managing multi-author blogs, I've often needed to maintain content quality by setting a minimum word count for posts. This simple, battle-tested code snippet integrates seamlessly into your theme's functions.php file, preventing publication of posts below your specified threshold and displaying a clear error message.
function minWord ($ content) global $ post; $ content = $ post-> post_content; if (str_word_count ($ content) < 100 ) //set this to the minimum number of words wp_die( __('Error: your post is below the minimum word count. It needs to be longer than 100 words.') ); add_action('publish_post', 'minWord');Customize the threshold (e.g., change 100 to your desired minimum) and tailor the error message for better user guidance. This approach has reliably upheld standards across numerous sites I've optimized.