I'm trying to trim the excerpt to only the first paragraph by adding filters to my theme's functions.php file. I have this working fine on my local machine (using WAMP), but on my actually web server it outputs the entire post rather than the paragraph I'm expecting. Here's what I have to trim the excerpt:
// Set the excerpt length to more than necessary
function triangle_x_excerpt_length($length)
{
return 999;
}
add_filter('excerpt_length', 'triangle_x_excerpt_length', 999);
// Get the first paragraph of the article
function triangle_x_excerpt($text, $raw_excerpt)
{
if(!$raw_excerpt)
{
$content = apply_filters( 'the_content', get_the_content() );
$text = substr( $content, 0, strpos( $content, '</p>' ) + 4 );
}
$text = preg_replace("/<img[^>]+\>/i", "", $text);
return $text;
}
add_filter('get_the_excerpt', 'triangle_x_excerpt', 20, 2);
// Remove read more link at end of excerpt
function new_excerpt_more($more)
{
return '';
}
add_filter('excerpt_more', 'new_excerpt_more');