admin管理员组文章数量:1327888
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";
本文标签: functionsExcerpt – First Sentence amp Read More
版权声明:本文标题:functions - Excerpt – First Sentence & Read More 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742231873a2437365.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
return $sentence['0'] . $sentence['1'] . "... Read More";
? – mozboz Commented Jul 26, 2020 at 16:04