This snippet will allow you to define a custom truncate length of the WordPress post title in your template files.
Instructions
Add this to your functions.php
file.
<?php
function cptl_title($char) {
$title = get_the_title($post->ID);
$title = substr($title,0,$char);
echo $title;
}
?>
And then add this to your template file where you want the post title to be displayed.
<?php cptl_title(100); ?>
*note – the number 100 is the characters allowed before title is being truncated. You can define any differently character amount on each post title thru-out your templates.
Comments