WordPress Snippets at WPcustoms

Variable post title length

This snippet will allow you to define a custom length post title in your template files.

 * Snippet Name: Variable post title length
 * Snippet URL: https://wpcustoms.net/snippets/variable-post-title-length/
  // usage: custom_title(50);   
// 50 is the character limit when the title gets truncated - change as required

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