Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jackfearing/ba215927b56805335f5ef55461f7baa8 to your computer and use it in GitHub Desktop.
Save jackfearing/ba215927b56805335f5ef55461f7baa8 to your computer and use it in GitHub Desktop.
/*
Quick Tip! What happens when your post title does not fit on one line? It wraps to the second line. What if it’s only one word? And what if that word is “it” or some other shorty? Your title won’t look too nice, eh? Here’s a solution, somewhere inside the loop:
*/
$title = the_title( '<h2>', '</h2>', false );
if ( strlen( $title ) > 0 )
echo substr_replace( $title, '&nbsp;', strrpos( $title, ' ' ), 1 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment