Thursday, 7 October 2021

How to Set a Minimum Word Count for WordPress Posts

Do you want to set a word count for your WordPress blog posts?

If you have multiple authors on your site, then setting up a minimum word count can help ensure that writers meet content standards and fully answer the reader’s questions.

In this article, we’ll show you how to set a minimum word count for your WordPress posts.

Set Minimum Word Count for WordPress Posts

Why Set a Minimum Word Count for Your Blog Posts?

Whether you’re creating content yourself or run a multi-author website, you should set certain content standards to ensure top quality articles.

One of the standards you can introduce is a minimum word count for each WordPress blog post. With WordPress, you can restrict authors from publishing blog posts with thin content and ensure high content quality.

Why would you want to enforce longer posts?

Some research suggests that longer content tends to rank significantly better in search results than short content, which could help you get more traffic to your blog.

That being said, let’s look at how you can set a minimum word count in a WordPress blog.

Method 1: Set a Minimum Word Count Using a Plugin

A simple way to add a minimum word count to your WordPress website is by using a plugin like PublishPress Checklists.

PublishPress Checklists allow you to set tasks that authors must complete before publishing content. This includes adding a minimum and maximum word count on posts and pages.

For this tutorial, you can use the free version of PublishPress Checklists, since it has the features we need. There’s also a premium version available that offers more features like checklists for WooCommerce products.

First, you’ll need to install and activate the PublishPress Checklists plugin. You can follow our step-by-step tutorial on how to install a WordPress plugin for more details.

Upon activation, you’ll need to go to Checklists from your WordPress admin panel. Next, you can set minimum and maximum words for the ‘Number of words in content’ option.

Change PublishPress Checklists settings

After that, you can choose whether you want to make the ‘Number of words in content’ option to be disabled, required, or recommended task from the dropdown menu.

If you select Recommended, then authors can publish articles even if they don’t meet the minimum word count. However, the Required option makes it mandatory to complete the word count task, so go ahead and select the Required option.

Besides that, PublishPress Checklists also lets you add user roles to exclude from meeting the word count requirement. Simply click on the box under the ‘Who can ignore the task’ column and select a user role.

Choose user roles to exclude

When you’ve set the number of words writers should complete, simply scroll down and click the ‘Save Changes’ button.

Save your changes

Now you can go to Posts » Add New to create a new blog post and see the minimum word count requirement in action.

If the post doesn’t contain the minimum number of words, a warning icon will appear on the ‘Publish’ button in the WordPress editor. The plugin will also show that the word count task wasn’t met in the ‘Checklist’ settings box on your right.

Minimum word count warning in editor

Once your content meets the minimum word count, the checklist task will show a green checkmark, and authors can publish the blog post.

Green checkmark when the checklist task is met

Method 2: Manually Set a Minimum Word Count Limit

Another way to add a minimum word count on your WordPress website is by adding a code snippet to the functions.php files in a WordPress theme.

However, we don’t recommend editing your site’s theme files. That’s because even a small mistake can break your website and even prevent you from accessing the WordPress dashboard.

An easier way to add code to your site is by using the Code Snippets plugin. It lets you add custom code without worrying about breaking your site. Plus, it makes it easier to keep track of any snippets you add to your site.

First, you’ll need to install and activate the Code Snippets plugin. If you need help, then check out our guide on how to install a WordPress plugin.

Once the plugin is active, simply head over to Snippets » Add New from your WordPress dashboard. You can start by adding a title for your custom code.

Add new code snippet

Now, you’ll need to copy the following code:

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

Note: You may change the minimum number of words from 100 to whatever you like and also customize the error to make it helpful. Make sure to change the number in both places in the code snippets.

Next, simply paste the copied code in your new snippet under the ‘Code’ area and then click the ‘Save Changes’ and ‘Activate’ buttons.

Save and activate your custom code

Now, if you try to publish a blog post that’s below the word count limit (100 words in our example), then you’ll see a publishing error.

Publishing error for not meeting word count

We hope this article helped you learn how to set a minimum word count for a WordPress blog. You may also want to look at how to create an email newsletter the right way, or see our expert pick of the best HR payroll software for small business.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

The post How to Set a Minimum Word Count for WordPress Posts appeared first on WPBeginner.



from WPBeginner https://ift.tt/3uRR7wI
More links is https://mwktutor.com

No comments:

Post a Comment