【发布时间】:2015-09-01 19:28:04
【问题描述】:
我有以下狙击手:
<div class="content">
<h2><?php echo $article->post_title ?></h2>
<h3><?php echo get_field( 'subtitle', $article->ID ); ?></h3>
<p><?php echo display_post_excerpt( $article->post_excerpt, $article->post_content ); ?></p>
</div>
这里是 display_post_excerpt 函数:
function display_post_excerpt( $excerpt, $content ){
if( $excerpt != '' ){
$text = $excerpt;
}else{
$text = $content;
}
$text = strip_tags( $text );
return $text;
}
我想限制帖子摘录(如果帖子没有摘录,还有内容)。我不知道我应该如何继续以及在哪里(在function.php中?模板?我想我应该使用类似的东西:
if (strlen($text) > 20) {
strlen($text) == 20;
}
但由于我是一个大菜鸟,我不确定。 你能帮帮人吗?
【问题讨论】: