我想限制get_the_content();如果最后一个字符落在一个单词中,即它之后没有空格,我想修剪回到之前有空格的前一个字符,然后将其存储在一个单词中。 get_the_content()。我该怎么做呢?
答案 0 :(得分:0)
您想使用filter。
类似的东西:
function my_the_content_filter($content) {
// wordwrap wraps a line after x number of characters but doesn't break words. then use regex to delete everything after the first linebreak.
echo preg_replace('/\\\n(.*)/', '', wordwrap ( $string, 100, '\n'));
return $content;
}
add_filter( 'the_content', 'my_the_content_filter' );