Limit the length of the post title

1) Limit display
With some themes, display the article title fix a specific size, If your title is too long will be dropped line or colon out, Thus, mess up your page takes, I will guide you how to install the limited display of title.
First open the file and add the following function function.php

function limited_title($char) {
$title = get_the_title($post->ID);$title = substr($title,0,$char);echo $title;
}

Now you open the index.php file,single.php… or where there are currently title, you see
the_title();
ice
limited_title(10);
Remember to change 10 the number of characters you want to make offline


2 ) Limits on arrival

And if you want to limit always when entering the title, then you can use the following functions to check the length of the header when posting articles.

Add file function.php

function maxWord($title){
global $post;
$title = $post->post_title;
if (str_word_count($title) >= 10 )
wp_die( __('loi : Tieu de dai qua do dai toi da.') );
}
add_action('publish_post', 'maxWord');
Good luck
VN:F [1.9.22_1171]
Rating: 4.0/5 (4 votes cast)

Limit the length of the post title, 4.0 out of 5 based on 4 ratings

  • http://www.facebook.com/dangkhoa491 Pdk Buzzed

    More specific guidance is not? Edited under the guidance of his themes still not been