i have recent comments and recents posts on a sidebar. And because of my design i want to limit the chars of the
- title on recent comments
- author on recent comments
- title on recents posts
Q: I looked into widget.php and can find the Recent comments function, but can't find the recent posts function?
Q: How can i limit the char on these title and author?
I did it on my title on the homepage, but that title is different.
The way how i did it on my homepage:
Functions.php:
// Limit the title char on the homepage
function short_title($before = '', $after = '', $echo = true, $length = false) {
$title = get_the_title();
if ( $length && is_numeric($length) ) {
$title = substr( $title, 0, $length );
}
if ( strlen($title)> 0 ) {
$title = apply_filters('short_title', $before . $title . $after, $before, $after);
if ( $echo )
echo $title;
else
return $title;
}
}
?>
On my index.php:
<?php short_title('', '', true, '40'); ?>
But they seems to be different at the recent comments..