I need my preview show only two sentences, how can I do it?
add_filter(
'the_excerpt',
function ($excerpt) {
return substr($excerpt,0,strpos($excerpt,'.')+1);
}
);
function excerpt_read_more_link($output) {
global $post;
$output = preg_replace('/(.*?[?!.](?=\s|$)).*/', '\\0', $output);
if(mb_strlen($output) > 300) {
$output = mb_substr($output, 0, 300);
}
return $output;
}
add_filter('the_excerpt', 'excerpt_read_more_link');
I have a code, that make it for first one sentence, but how can I fix it to show two?