Revision: 48851
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at July 11, 2011 21:13 by kai330
Initial Code
<?php
//this part goes to functions.php
function string_limit_words($string, $word_limit)
{
$words = explode(' ', $string, ($word_limit + 1));
if(count($words) > $word_limit) {
array_pop($words);
//add a ... at last article when more than limit word count
echo implode(' ', $words)."..."; } else {
//otherwise
echo implode(' ', $words); }
}
//this part goes to template
$excerpt = get_the_excerpt();
echo string_limit_words($excerpt,25);
?>
Initial URL
http://wordpress.org/support/topic/limit-the-number-of-words-in-excerpt-without-plugins
Initial Description
Initial Title
Wordpress excerpt custom word limitation
Initial Tags
wordpress
Initial Language
PHP