是的,您可以这样做,但您需要调整<?php the_excerpt(); ?>
作用这是一篇关于如何做到这一点的好文章:
http://aaronrussell.co.uk/legacy/improving-wordpress-the_excerpt/
为了总结这篇文章,以防它消失,把它放在你的主题功能中。php文件:
function improved_trim_excerpt($text) {
global $post;
if ( \'\' == $text ) {
$text = get_the_content(\'\');
$text = apply_filters(\'the_content\', $text);
$text = str_replace(\'\\]\\]\\>\', \']]>\', $text);
$text = preg_replace(\'@<script[^>]*?>.*?</script>@si\', \'\', $text);
$text = strip_tags($text, \'<img>\');
$excerpt_length = 80;
$words = explode(\' \', $text, $excerpt_length + 1);
if (count($words)> $excerpt_length) {
array_pop($words);
array_push($words, \'[...]\');
$text = implode(\' \', $words);
}
}
return $text;
}
remove_filter(\'get_the_excerpt\', \'wp_trim_excerpt\');
add_filter(\'get_the_excerpt\', \'improved_trim_excerpt\');
注意这一行,这是告诉函数除去除
<img>
标签。如果希望包含段落标记或其他内容,可以添加其他内容:
$text = strip_tags($text, \'<img>\');
然后调用\\u摘录();像往常一样,在主题文件中(index.php、single.php等)。
祝你好运!