此函数调用作者的所有注释,并将每个注释剥离到最大长度。在模板中调用函数时调整注释摘录长度,如wpse19316_author_comments( 100 );
.
function wpse19316_author_comments( $length )
{
$final_length = (int) $length;
$author_comments = get_comments( array( \'ID\' => $GLOBALS[\'authordata\']->ID ) );
foreach ( $author_comments as $comment )
{
$comment_length = sublen( $comment->comment_content );
$comment_excerpt = $comment->comment_content;
if ( $comment_length > $final_length )
$comment_excerpt = substr( $comment->comment_content, $final_length );
echo $comment_excerpt.\'<br />\';
}
}