Limiting Characters without cutting a word in half
-
Hey all,
I’m trying to return a title of a post while cutting it after 35 or so characters. Right now I have:
"> <?php echo substr(get_the_title(), 0, 35); if(strlen(get_the_title()) > 20) echo ' ...'; ?>
But it of course cuts off the string after the character limit. Can anyone help me make it so that it won’t cut a word in half? I know Drupal has some function that covers this but I’m not sure about WP!
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Limiting Characters without cutting a word in half’ is closed to new replies.