Minimum Word Count: How To Define One For Your Posts

Steven2 responsesWordPress

You may want to make sure that all the posts published on your WordPress blog have a minimum word count, especially if you are allowing guest contributors to post on your blog. This can also help maintaining a clean layout and a decent post quality.

To enable this WordPress hack, paste the following code in your functions.php file. This code will automatically raise an error whenever someone tries to publish a post which doesn’t have more words that the minimum number of words defined.

Learn how I made $33,543 online in the past 12 months.

Simply input your best email below to get started.

function minWord($content){
  global $post;
        $num = 300; //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');

You’re all set. The 300 number means that your posts will need to have a minimum of 300 words. If you want to change the minimum word count, feel free to change this number.

Learn how I made $33,543 online in the past 12 months.

Simply input your best email below to get started.

2 Comments

  1. Affiliate Manager

    Interesting. I think there may be instances where you might not want this, but overall it’s definitely important to keep your post count high. I usually go for at least 500 words on my articles. Thanks for the programming tip!

    1. Of course if your websites is about haikus, you don’t want to use this snippet of code ;) But overall, it allows you to make sure your blog posts have a minimum length without having to manually check.

Learn how I made $33,543 online in the past 12 months.

Simply input your best email below to get started.

No thanks, I have enough money