Help pls trying to update the_title in wordpress

Hi Guys,

I’ve been struggling with how to limit the length of a post title in wordpress…? I’ve got as far as it will limit what is displayed on the screen, but the problem is it is not updating or changing the original length of the title, Which is a major problem if I submit a post to Twitter for example.
The code:
[php]function the_title_shorten($len,$rep=’…’) {
$title = the_title(’’,’’,false);
$shortened_title = textLimit($title, $len, $rep);
print $shortened_title;

//shorten without cutting full words (Thank You Serzh ‘’)
function textLimit($string, $length, $replacer) {
if(strlen($string) > $length)
return (preg_match(’/^(.)\W.$/’, substr($string, 0, $length+1), $matches) ? $matches[1] : substr($string, 0, $length)) . $replacer;

return $string;

Does anyone know how to get the_title in wordpress to update to the truncated version of the title that gets displayed on the screen…?

Thanks Steve

Sponsor our Newsletter | Privacy Policy | Terms of Service