Skip to content

How To Set Minimum Word Count For WordPress Posts

Since the recent Google search algorithm updates it’s more important for writers to focus on their posts and content. You can no longer post an article with a few words and some high ranked keywords in the title. Now, you need to write an article with a lot of quality content and keywords.

If you’re running a WordPress website with contributors or co-authors, then it’s more important for you to maintain your blog’s content quality. With WordPress, you can set minimum word count for your posts.

Add following snippet to your functions.php file:

function minimum_number_words($content)
{
    global $post;
    $content = $post->post_content;
    if (str_word_count($content) < 500 )
    wp_die( __('The current post is below the minimum number of words, it must be over 500 words.') );
}

<

p>The above code will check if the post is below 500 words and if it is then your post will not be published. You can change minimum word count by changing the number in 5th line of above code.

1 thought on “How To Set Minimum Word Count For WordPress Posts”

  1. When I use this code snippet I receive the warning message about the minimum word count, but the post publishes anyway. Is anyone else having this issue?

Leave a Reply

Your email address will not be published. Required fields are marked *