How to set minimum word count on WordPress posts – Learn WordPress from a to z

Tutorials 0 lượt xem

If you want to limit the number of words for your WordPress posts, then this is the article for you. When there are multiple authors involved on your site, setting limits is important. It ensures the author meets the content standard and meets the needs of the reader. Don’t miss the article below!

Minimum word limit

Why set a minimum word count for your blog posts?

Whether you’re a blogger or run a multi-author website, you should set standards for content to ensure the best quality articles.

One standard you can apply is the minimum word count per WordPress post. With WordPress, you can restrict authors from publishing unqualified articles and ensure high quality content.

Why do posts need to be longer and more complete?

Statistics show that longer content tends to rank significantly better in search results than shorter content. This can help you get more traffic to your blog. Check out how to do it effectively below!

Set the minimum word limit manually

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

However, I do not recommend editing your site’s theme files. Because even a small mistake can ruin or prevent you from accessing the WordPress dashboard.

An easier way to add code to your site is to use the Code Snippets plugin . It allows you to add custom code without worrying about breaking your site. Furthermore, it becomes easier to keep track of any code snippets you add to your site.

First, you need to install and activate the Code Snippets plugin. Once the plugin is up and running, simply visit Snippets » Add New from the WordPress dashboard. You can start by adding a header to your custom code.

add new code snippets

Next you need to copy this code.

function minWord( $content ) {
    global $post;
    $content = $post->post_content;
    if ( str_word_count($content) <span>1</span><span>2</span><span>3</span><span>4</span><span>5</span><span>6</span><span>7</span>

Note: You can change the minimum word count from 100 to any number you like and also customize the error to make it useful. Make sure to change the number in both places in the code snippets. Next, paste that code into the new snippet under “Code”, then click the “Save Changes” and “Active” buttons.

If you post a post below the limit (under 100 words, for example), you’ll see a publishing error.

how error reporting works

Epilogue

I hope this article will help you build a blog with quality content.

If you find it interesting, you can follow the  WordPress basics section  to know more new knowledge.

Follow fanpage to receive the latest posts:  Group

Bài viết liên quan