Posted By

gd6d on 09/24/10


Tagged

words wordpress function title


Versions (?)

How to set a maximum word count on post titles


 / Published in: PHP
 

URL: http://www.wprecipes.com/how-to-set-a-maximum-word-count-on-post-titles?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+Wprecipes+%28WpRecipes.com%3A+Daily+recipes+to+cook+with+WordPress%29

  1. function maxWord($title){
  2. global $post;
  3. $title = $post->post_title;
  4. if (str_word_count($title) >= 10 ) //set this to the maximum number of words
  5. wp_die( __('Error: your post title is over the maximum word count.') );
  6. }
  7. add_action('publish_post', 'maxWord'

Report this snippet  

You need to login to post a comment.