If you want to shorten your Wordpress post titles add the function below to your functions.php file.

function the_title_limit($length, $replacer = '...') {
 $string = the_title('','',FALSE);
 if(strlen($string) > $length)
 $string = (preg_match('/^(.*)\W.*$/', substr($string, 0, $length+1), $matches) ? $matches[1] : substr($string, 0, $length)) . $replacer;
 echo $string;
}

And then paste this snippet where you want to be displayed:

<?php the_title_limit( 30, '...'); ?>
 

Leave a Comment

You must be logged in to post a Review.