php theexcerpt,WordPress:the excerpt(摘要)

翻译自WordPress Chinese 中文文档

Description

描述

Displays the excerpt of the current post with […] at the end, which is not a read more link. If you do not provide an explicit excerpt to a post (in the post editor's optional excerpt field), it will display a teaser which refers to the first 55 words of the post's content. Also in the latter case, HTML tags and graphics are stripped from the excerpt's content. This tag must be within The Loop.If the current post is an attachment, such as in the attachment.php and image.php template loops, then the attachment caption is displayed. Captions do not include the excerpt […] marks.

显示当前文档的摘要,并且在末尾添加[…],它并不是一个更多阅读的链接。如果你不提供一个显示的摘要在一个文章里面(在文章编辑器里有可选摘要域),它将显示一个teaser,自动的截取文章内容的前55个单词。随之的情景,HTML标签以及图形将在摘要中被忽略掉。这个标签必须在Loop内。如果当前的文档是一个附件,正像在attachment.php和image.php模板中的Loop一样,这样附件标题将被显示出来。标题不会包括摘要的[…]标记。

Usage

使用方法

%%% ?php the_excerpt(); ? %%%

Examples

例子

Default Usage

默认的使用方法

Displays the post excerpt. Used on non-single/non-permalink posts as a replacement for the_content() to force excerpts to show within the Loop.

显示文章摘要。在非单独或非永久性链接的文章中使用,从而替换the_content()在Loop当中强制显示摘要。

?php the_excerpt(); ?

Use with Conditional Tags

附加标签的使用

Replaces the_content() tag with the_excerpt() when on archive (tested by ttis_archive()/tt) or category (ttis_category()/tt) pages.

Both the examples below work for versions 1.5 and above.

在文档(用ttis_archive()/tt测试)或目录(ttis_category()/tt)中用the_excerpt()替换the_content()。

下面的例子都适用于WordPress1.5以上的版本.

%%% ?php if(is_category() || is_archive()) {

the_excerpt();

}

else {

the_content();

} ? %%%

For versions of WordPress prior to 1.5, only the following will work :

只有下面的代码适用于WordPress1.5以前的版本:

%%% ?php if($cat || $m) {

the_excerpt();

}

else {

the_content();

} ? %%%

Parameters

参数

This tag has no parameters.

这个标签没有参数。

Comparison of the_excerpt() vs. the_content()

对比the_excerpt()和 the_content()

Sometimes is more meaningful to use only the_content() function. the_content() will decide what to display according to whether %%%!–more–%%% tag was used. %%%!–more–%%% tag splits post/page into two parts: only content before tag should be displayed in listing. Remember that %%%!–more–%%% is (of course) ignored when showing only post/page (singles).

仅仅使用the_content()函数,有时候也是非常有意思的。根据是否使用%%%!–more–%%% 标签,the_content()决定将显示什么内容。 %%%!–more–%%%标签将文章或页分成两部分:在列表中仅仅显示出标签前面的内容。 当然要记住%%%!–more–%%%标签在单独的文章或页当中将被忽略掉。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值