Last active
December 31, 2015 04:59
-
-
Save sharpmachine/7937825 to your computer and use it in GitHub Desktop.
Creates a short title from the_title
This file contains hidden or 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
| //Put in functions.php | |
| function short_title($limit) { | |
| global $post; | |
| $title = get_the_title($post->ID); | |
| if(strlen($title) > $limit) { | |
| $title = substr($title, 0, $limit) . '...'; | |
| } | |
| echo $title; | |
| } | |
| //Call in template file | |
| <?php the_short_title(30); ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment