wordpress snippets last updated   : January 29, 2015
we now have 646 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 →

Did you like this post? If so please share it with your friends. Thanks!