Created
January 12, 2012 17:31
-
-
Save ramseyp/1601913 to your computer and use it in GitHub Desktop.
shorten user descriptions - WordPress
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 | |
// filter user description to return something shorter | |
add_filter ( 'pre_user_description', 's25_short_description' ); | |
function s25_short_description($description) { | |
$max_characters = 50; | |
if ( strlen( $description ) > $max_characters ) { | |
$description = substr( $description, 0, $max_characters + 1 ); | |
$description = trim( substr( $description, 0, strrpos( $description, ' ' ) ) ); | |
} | |
return $description; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment