Return to Snippet

Revision: 56996
at April 29, 2012 20:08 by webtechdev


Initial Code
function wp_new_excerpt($text)
{
	if ($text == '')
	{
		$text = get_the_content('');
		$text = strip_shortcodes( $text );
		$text = apply_filters('the_content', $text);
		$text = str_replace(']]>', ']]>', $text);
		$text = strip_tags($text);
		$text = nl2br($text);
		$excerpt_length = apply_filters('excerpt_length', 55);
		$words = explode(' ', $text, $excerpt_length + 1);
		if (count($words) > $excerpt_length) {
			array_pop($words);
			array_push($words, '[...]');
			$text = implode(' ', $words);
		}
	}
	return $text;
}
remove_filter('get_the_excerpt', 'wp_trim_excerpt');
add_filter('get_the_excerpt', 'wp_new_excerpt');

Initial URL


Initial Description
You can just re-write the excerpt function in your theme functions file...
ust change this line...

array_push($words, '[...]');

You can also change the character limit here...

$excerpt_length = apply_filters('excerpt_length', 55);

Initial Title
the_except() remove [...]  or add any custom words

Initial Tags


Initial Language
PHP