add the following to functions file

/**
* Avoid Typography Widows
*/
function kl_avoid_content_widows( $content ) {
$pattern = ‘@(?:\s)([[:punct:][:word:]]+)(?:\s)(?!/>)([[:punct:][:word:]]+)(?:\s)([[:punct:][:word:]]+)</(p|h1|h2|h3|h4|h5|h6)>@m’;
$replacement = ‘ $1 $2 $3</$4>’;
$content = preg_replace( $pattern, $replacement, $content, -1 );

return $content;
}
add_filter( ‘the_content’, ‘kl_avoid_content_widows’ );