How to set maximum post title length on WordPress

Sometimes you need to limit the maximum length of a WordPress post title, in such situation you can use below code snippet. Simply copy and paste below PHP code to your functions.php in theme folder and this will limit the length of title.

function limit_Title($title){
    global $post;
    $title = $post->post_title;
    if (str_word_count($title) >= 8 ) //Set the maximum number of words here
        wp_die( __('Error: Opps... your post title is over the maximum limit.') );
add_action('publish_post', 'limit_Title');

Related posts:

HTML5 page structure

HTML5 offers more powerful structure comparing to older versions of Html. There are many new …

Partner with Us

We are providing an exclusive partnership offer to individuals and companies who are interested in setting up their own web design & development company. For more information about how to partner with us, please contact us