Hi John S,
Please follow these steps:
1. Open your theme’s functions.php file.
2. Add the following code:
function better_trim_excerpt($text)
{
$raw_excerpt = $text;
if ( ” == $text ) {
$text = get_the_content(”);
$text = strip_shortcodes( $text );
$text = apply_filters(‘the_content’, $text);
$text = str_replace(‘]]>’, ‘]]>’, $text);
// Removes any JavaScript in posts (between <script> and </script> tags)
$text = preg_replace(‘@<script[^>]*?>.*?</script>@si’, ”, $text);
// Enable formatting in excerpts – Add HTML tags that you want to be parsed in excerpts, default is 55
$text = strip_tags($text, ‘<strong><b><em><i><a><code><kbd><ul><li>
‘);
// Set custom excerpt length – number of words to be shown in excerpts
$excerpt_length = apply_filters(‘excerpt_length’, 55);
// Modify excerpt more string at the end from […] to …
$excerpt_more = apply_filters(‘excerpt_more’, ‘ ‘ . ‘…’);
$words = preg_split(“/[\n\r\t ]+/”, $text, $excerpt_length + 1, PREG_SPLIT_NO_EMPTY);
if ( count($words) > $excerpt_length ) {
array_pop($words);
$text = implode(‘ ‘, $words);
// IMPORTANT! Prevents tags cutoff by excerpt (i.e. unclosed tags) from breaking formatting
$text = force_balance_tags( $text );
$text = $text . $excerpt_more;
} else {
$text = implode(‘ ‘, $words);
}
}
return apply_filters(‘wp_trim_excerpt’, $text, $raw_excerpt);
}
// Remove the native excerpt function, and replace it with the improved function
remove_filter(‘get_the_excerpt’, ‘wp_trim_excerpt’);
add_filter(‘get_the_excerpt’, ‘better_trim_excerpt’);
However, my plugin disables the formatting of the markup ul. So, I will need to release another version but it will take me sometime because I am working in other projects by now.
Hope this helps you in the meantime,
Lebasca