Last active
August 29, 2015 14:21
-
-
Save moughamir/c2589881262dc8346d9c to your computer and use it in GitHub Desktop.
Truncate Post Title
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment