Hi Friends i am using Author widget plugin. This echo author biographic info in sidebar.
The Author description part is also showing in sidebar i want limit description character length and put readmore text in next line. currently description echo now through this code:
<?php If ($author->description) : ?>
<?php Echo nl2br($author->description)?>
<?php EndIf ?>
Need Help Friends.
webdesignerart said
Hi Friends i am using Author widget plugin. This echo author biographic info in sidebar.
The Author description part is also showing in sidebar i want limit description character length and put readmore text in next line. currently description echo now through this code:
<?php If ($author->description) : ?>
<?php Echo nl2br($author->description)?>
<?php EndIf ?>
Need Help Friends.
echo substr($author->description,0,strpos($author->description,' ',30));
you could limit to 30 chars.
This will truncate to a specified # of characters, but not in the middle of a word, and append your custom html to the end
function fs_truncate($content,$length,$after='...') {
// rather than just use substr, let's make sure we cut it at the end of a word
$arr = explode(' ', $content);
$out = '';
$count = 0;
foreach( $arr as $str ){
$count += ( strlen($str) + 1); // +1 is for the space we removed
if ($count > $this->length)
break;
$out .= $str . ' ';
}
// make sure we got SOMEthing
if (!$out) {
$out = $arr[0];
}
$out = trim($out);
$out .= $after;
return $out;
}
chrismccoy said
webdesignerart said
Hi Friends i am using Author widget plugin. This echo author biographic info in sidebar.
The Author description part is also showing in sidebar i want limit description character length and put readmore text in next line. currently description echo now through this code:
<?php If ($author->description) : ?>
<?php Echo nl2br($author->description)?>
<?php EndIf ?>
Need Help Friends.
echo substr($author->description,0,strpos($author->description,' ',30));
you could limit to 30 chars.
I use this code its works for me
and thankx for your time.
<?php $author_desc = nl2br($author->description);
echo substr($author_desc,0,150).'[...]'; ?>
webdesignerart said
I use this code its works for me
and thankx for your time.
<?php $author_desc = nl2br($author->description);
echo substr($author_desc,0,150).'[...]'; ?>
Use Chris’s code, so you don’t cut your text in the middle of a wo…
