IOM Partners of Houston

A comprehensive range of Houston Website Design Services now on offer from IOM Houston which is the market as well as segment leader in web design and development solutions through its professional team of website designers who possess years of industry s

Setting a Minimum Word Count for the Posts on Your WordPress Website

WordPress is perhaps the most versatile Content Management System as you can create a wide range of websites based on WordPress. Now, if you want to have a blogging website, where you allow a number of writers to post blogs, then WordPress would help you to create such a website. However, there are a few things that you should do to maintain the standard of such a website. One such thing is setting a minimum word limit for the posts. This would prevent your bloggers from writing a short post as that would create an inconsistency in the quality of the posts. Now, you can do that for your WordPress website with ease. In this post, we are going to look at the process by which you can limit the number of words in your WordPress website.

 

 

 

Before we start, we would like to point out that you would need to make some changes to the code of your website. If you are not comfortable with changing the codes yourself, you can take the help of a professional web designer. The city of Houston, TX has some of the well-known web design companies. You can hire such an expert in the field of Web Design in Houston and get the job done without any hassles.

 

 

To limit the word count for your posts, you need to paste the following code in the functions.php file of your theme


1

function minWord($content)

 

2

{

 

3

    global $post;

 

4

    $content = $post->post_content;

 

5

    if (str_word_count($content) < 100 ) //set this to the minimum number of words

 

6

    wp_die( __('Error: your post is below the minimum word count. It needs to be longer than 100 words.') );

 

7

}

 

8

add_action('publish_post', 'minWord');

 

Note that in the given code we have limited the number of words to 100 (look at line number 5 in the code). When a blogger tries to upload a post that is less than 100 words in length, then this code would prevent that from happening and would display an error message that says 'Error: your post is below the minimum word count. It needs to be longer than 100 words.'

 

 

You can change the word limit by entering your desired number. You can even edit the error message to something that you like.

 

 

If you want to design a truly amazing website, then taking the help of the most reputed Houston Website Design Company seems to be the right way. They would help you design a website just like you want it to be. So, take the help of the experts in web design and design a website of your dreams.