该标签在wordpress中与the content相似。
the excerpt
-描述:
显示当前post的摘要以[...]结尾,并非一个”阅读更多”的链接 。如果在wordpress后台编辑文章是没有指定摘要内容,该标签显示内容的头55个词。摘要内容不会包括html标签和图像。该标签须在循环内。
注意:
若当前文章是个附件,比如在attachment.php和image.php模板循环内,那么只显示它的说明。
-使用:
<?php the_excerpt(); ?>
-参数:
无
-例子:
1.显示摘要。用在非single页或非链接文章页循环内代替the_cntent显示摘要。
<?php the_excerpt(); ?>
2.在归档页或分类页代替the_cntent。
1)适用于1.5或更高版本:
<?php if ( is_category() || is_archive() ) {
the_excerpt();
} else {
the_content();
} ?>
2)适用于较1.5更低的版本:
<?php if ( $cat || $m ) {
the_excerpt();
} else {
the_content();
} ?>
3.默认摘要显示55个词,下面的代码加入主题中的function.php文件可以改变摘要长度。
function new_excerpt_length($length) {
return 20;
}
add_filter(‘excerpt_length’, ‘new_excerpt_length’);
有时候the_content()更灵活,它可以根据<!–more–>在文章内的随意插入,而显示more之前的内容。
这里有英文原版文档。
右上方更多相关内容/站内搜索-关键词请用空格隔开
发表留言