wordpress snippets last updated   : April 14, 2014
we now have 630 snippets

Set maximum post title length

wordpress snippet

Adding this PHP code to the functions.php of your wordpress theme will set a maximum number of words that can be displayed within your post title.

snippet :  PHPcopy
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');
source →
jqsnipp.com | we just launched jquery snippets website