I am using this function to limit the excerpt to the first sentence...
function hello_first_sentence( $string ) {
$sentence = preg_split( '/(\.|!|\?)\s/', $string, 2, PREG_SPLIT_DELIM_CAPTURE );
return $sentence['0'] . $sentence['1'];
} add_filter( 'get_the_excerpt', 'hello_first_sentence', 10, 1 );
However, for some reason, I am unable to add the "read more" after the excerpt... any help?
I am using this function to limit the excerpt to the first sentence...
function hello_first_sentence( $string ) {
$sentence = preg_split( '/(\.|!|\?)\s/', $string, 2, PREG_SPLIT_DELIM_CAPTURE );
return $sentence['0'] . $sentence['1'];
} add_filter( 'get_the_excerpt', 'hello_first_sentence', 10, 1 );
However, for some reason, I am unable to add the "read more" after the excerpt... any help?
Share Improve this question asked Jul 25, 2020 at 17:36 PauloPPauloP 516 bronze badges 8 | Show 3 more comments1 Answer
Reset to default 1To append strings in PHP use .
, like:
return $sentence['0'] . $sentence['1'] . "... Read More";
return $sentence['0'] . $sentence['1'] . "... Read More";
? – mozboz Commented Jul 26, 2020 at 16:04