Excerpt filter is adding ” in incorrect place

It happens because using explode() to parse HTML is at least equally evil as trying to do it with regex. To “fix” it, the quick ’n dirty way, you could add the following preg_replace() after the implode() line: $wpse0001_excerpt = implode( ‘</p>’, $tmp_to_add ).'</p>’; $wpse0001_excerpt = preg_replace( ‘/<\/p>\s*<\/p>/’, ‘</p>’, $wpse0001_excerpt ); Using something like PHP’s … Read more

Limit article to 100 characters. Can’t use the_excerpt…

function get_custom_excerpt( $content, $link ){ $content = some_function_to_handle_html_tag(substr($content, 0, 100)); // EDIT: need to be customized with a regex for proper output $content .= ‘ <a href=”‘.$link.'”> more… </a>’; return $content; } function some_function_to_handle_html_tag(){ //a regex to check last occurance of html opening tag //append respective closing tag or strip the tag if broken e.g. … Read more