Limit the_excerpt to a fixed number of characters
A function to output a certain number of words from your WordPress content is useful, but you also may want to output to a certain number of characters.
Place the below function, which also encodes the content into UTF-8, in functions.php file.
/*
* Limit the_excerpt to a certain number of character
*/
function excerpt($num) {
echo utf8_encode(substr(get_the_excerpt(), 0, $num+1)) . "...";
}
The the_excerpt(); function needs to be replaced with excerpt(“25″) where 25 is your number of maximum characters to output.
You can remove the three dots appended to each new excerpt by removing the . “…”.
