moughamir
5/26/2015 - 8:51 AM

Truncate Post Title

Truncate Post Title

<?php
/**
 * Paste this function in your functions.php file,
 * and whenever you’re in need of truncating a title,
 * call: . Where (50) is the number of Characters it allows before truncating!
*/

function customTitle($limit) {
    $title = get_the_title($post->ID);
    if(strlen($title) > $limit) {
        $title = substr($title, 0, $limit) . '...';
    }
    
    echo $title;
}
?>