WordPress Admin – Set minimum word count for posts

How to Set Minimum Word Count on Posts

Implementation

1. Either code and paste the code into your themes functions.php or child theme
2. If you are not that technical then install the WordPress Snippets plugin


* @snippet  WordPress Admin - Set minimum word count for posts
 * @code    https://techskilled.co.uk/snippets/wordpress-admin-set-minimum-word-count-for-posts
 * @author  https://techskilled.co.uk
 */ 
function techskilled_minimum_wordcount($content){
   global $post;
   $num = 300; //set 300 min words
   $content = $post->post_content;

   if (str_word_count($content) < $num)
      wp_die( __('Error: Please write at least 300 words.') );
   }

add_action('publish_post', 'techskilled_minimum_wordcount');

NEED HELP?

If you are struggling to implement the SVG snippet then we can help from £9.99 - use our contact form below and we will get straight back to you!

HELP ME IMPLEMENT THIS SNIPPET

Leave a comment

Shares