Created
February 27, 2013 04:20
-
-
Save omurphy27/5045049 to your computer and use it in GitHub Desktop.
Wordpress PHP Shorten 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
<?php | |
// Shorten the Wordpress Title | |
// how to shorten the title in wordpress | |
echo substr(the_title('', '', FALSE), 0, 40); | |
// check here for more info: http://wordpress.org/support/topic/how-to-limit-character-on-title | |
// This is how i shorten the title and make sure to append '...' on the end of it: | |
// Make sure to define this guy first: | |
$title_string = strlen(get_the_title()); | |
// then put the following down below where you want the title | |
echo substr(the_title('', '', FALSE), 0, 50) ; | |
if ( $title_string > 50 ) { | |
echo '...' ; | |
} else { | |
echo ' '; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment