Truncate recent item titels
-
Hi all,
Im using a template that output’s title’s like this:
$output .= '<figcaption class="item-description"><h5>'.get_the_title().'</h5>';
Then i added some code to my functions.php:
/* Truncate Title */ function truncate_title($limit) { $title = get_the_title($post->ID); $getlength = strlen($title); $title = substr($title, 0, $limit); if ($getlength > $limit){ $title .= '...'; } echo $title; }
And then changed the template to:
$output .= '<figcaption class="item-description"><h5>'.truncate_title(60).'</h5>';
This doesnt work (ofcourse).. can somebody help me with this?
Thanks in advance!
- The topic ‘Truncate recent item titels’ is closed to new replies.