Some times we add some long title in some posts which are in a very narrow space, the title can not stay in one line for being long and narrow space. We can easily solve this problem by an easy way.

This is an easy way to make Custom post title length in wordpress by php. Now follow the code below,

<h2><a href="<?php the_permalink(); ?>"><?php if (strlen($post->post_title) > 12) {
echo substr(the_title($before = '', $after = '', FALSE), 0, 10) . '...'; } else {
} ?></a></h2>

Add this code instead of your title. You can change the title from ( h1-h6) and make the length 12 character to …..  how much you need. Remember every space and and dote (.) is a character.

Enjoy and keep learning