Created
January 4, 2012 16:41
-
-
Save ramseyp/1560867 to your computer and use it in GitHub Desktop.
Truncate WordPress 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 | |
/** | |
* Truncate WordPress post title | |
* @author Pat Ramsey | |
* @link | |
* | |
* @param $title, $limit | |
*/ | |
function s25_trunc_title( $limit ) { | |
global $post; | |
$title = get_the_title ( $post->ID ); | |
if ( strlen( $title ) > $limit ) { | |
$title = substr ( $title, 0, $limit ) . '...'; | |
} | |
return $title; | |
} | |
// | |
// usage: echo s25_trunc_title($limit); | |
// | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment