[wp-hackers] Re: filter the_exceprt
Daniel Cameron
dan at sproutventure.com
Mon Jan 12 01:07:48 GMT 2009
>
>
> I'm basically trying to get rid of that horrible [...] ellipses forces on
> the_exceprt, so maybe you have another solution (without a plugin).
>
>
I noticed I needed to set the priority. Here's what I'm working with now,
although there's no output.
add_filter('get_the_excerpt', 'sp_excerpt', 1, 2);
function sp_excerpt($text) { // Fakes an excerpt if needed
if ( '' == $text ) {
$text = get_the_content('');
$text = strip_shortcodes( $text );
$text = apply_filters('the_content', $text);
$text = str_replace(']]>', ']]>', $text);
$text = strip_tags($text);
$excerpt_length = 55;
$words = explode(' ', $text, $excerpt_length + 1);
if (count($words) > $excerpt_length) {
array_pop($words);
array_push($words, 'Read More');
$text = implode(' ', $words);
}
}
return $text;
}
More information about the wp-hackers
mailing list