if ( ! function_exists( 'custom_wp_trim_excerpt' ) )
{
function custom_wp_trim_excerpt($excerpt)
{
global $post;
$raw_excerpt = $excerpt;
if ( $excerpt == '' )
{
$excerpt = get_the_content('');
$excerpt = strip_shortcodes( $excerpt );
$excerpt = apply_filters('the_content', $excerpt);
$excerpt = substr( $excerpt, 0, strpos( $excerpt, '</p>' ) + 4 );
$excerpt_readmore = ' » <a href="'. esc_url( get_permalink() ) . '">Read More</a>';
$excerpt_more = apply_filters('excerpt_more', ' ' . $excerpt_readmore);
$pos = strrpos($excerpt, '</');
if ($pos !== false)
$excerpt = substr_replace($excerpt, $excerpt_readmore, $pos, 0);
else
$excerpt .= $excerpt_readmore;
return $excerpt;
}
return apply_filters('custom_wp_trim_excerpt', $excerpt, $raw_excerpt);
}
}
remove_filter('get_the_excerpt', 'wp_trim_excerpt');
add_filter('get_the_excerpt', 'custom_wp_trim_excerpt');