This bit of code will allow us to set a maximum word count to the post title. Very useful if you need to limit the length of titles for design purposes. To apply this hack, simply paste the following in your functions.php file:
function maxWord($title)
{
global $post;
$title = $post->post_title;
if (str_word_count($title) >= 10 ) //set this to the maximum number of words
wp_die( __('Error: your post title is over the maximum word count.') );
}
add_action('publish_post', 'maxWord');
{ 0 comments }
Continue Reading