嗯,您可以使用多种方法。其中之一显然是使用 the_excerpt();在您的模板中。如果您想在该摘录中添加更多字符(默认值除外)
那些)在你的functions.php文件中尝试这段代码
function new_excerpt_length($length) {
return 50;
}
add_filter('excerpt_length', 'new_excerpt_length');
function the_titlesmall($before = '', $after = '', $echo = true, $length = false) { $title = get_the_title();
if ( $length && is_numeric($length) ) {
$title = substr( $title, 0, $length );
}
if ( strlen($title)> 0 ) {
$title = apply_filters('the_titlesmall', $before . $title . $after, $before, $after);
if ( $echo )
echo $title;
else
return $title;
}
}
只需将return 50 更改为您想要的任何长度
另一种选择:在模板中使用 content() 函数,并在 functions.php 页面中使用:
function content($limit) {
$content = explode(' ', get_the_content(), $limit);
if (count($content)>=$limit) {
array_pop($content);
$content = implode(" ",$content).' <a class="seemore" href="'. get_permalink($post->ID) . '">More</a>';
} else {
$content = implode(" ",$content);
}
$content = preg_replace('/\[.+\]/','', $content);
$content = apply_filters('the_content', $content);
$content = str_replace(']]>', ']]>', $content);
return $content;
}
现在你可以在你的模板中使用<?php echo content(50); ?>(或者用你想要的任何长度替换那50个)
最后,您还可以在帖子/页面编辑屏幕中使用MORE 标签