WordPress: Template Tags/the excerpt:修订间差异

来自站长百科
跳转至: 导航、​ 搜索
(新页面: == 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 edito...)
 
 
(未显示2个用户的10个中间版本)
第1行: 第1行:
== 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 [[WordPress:Glossary#Excerpt|teaser]] which refers to the first 55 words of the post's content. Also in the latter case, [[WordPress:Glossary#HTML|HTML]] tags and graphics are stripped from the excerpt's content. This tag must be within [[WordPress:The Loop]].
显示当前文章的摘录,结尾有[...],[...]并不是一个"阅读更多"链接。如果你没有提供一篇清晰明了的文章摘录(在文章编辑器的可选择的摘录区),标签会显示[[WordPress:Glossary#Excerpt|teaser]],指的是文章内容的前55个字。同时在后一种情况下,[[WordPress:Glossary#HTML|HTML]]标签和图形都从摘录内容中清除了。必须在[[WordPress:The Loop|The Loop]]内使用这个标签。


== Usage ==
== 用法 ==


%%% <?php the_excerpt(); ?> %%%
%%% <?php the_excerpt(); ?> %%%


== Examples ==


=== Default Usage ===
==例子 ==


Displays the post excerpt. Used on non-single/non-permalink posts as a replacement for [[WordPress:Template_Tags/the_content|the_content()]] to force excerpts to show within the Loop.
=== 默认用法 ===


<?php the_excerpt(); ?>
显示文章摘录。将非单一/非permalink的文章用在一个代替品,替换[[WordPress:Template_Tags/the_content|the_content()]],迫使摘录在Loop内显示。


=== Use with Conditional Tags ===


Replaces the_content() tag with the_excerpt() when on archive (tested by <tt>is_archive()</tt>) or category (<tt>is_category()</tt>) pages.
<?php the_excerpt(); ?>


Both the examples below work for versions 1.5 and above.
=== 与条件式标签一起使用 ===
 
在归档网页(由 <tt>is_archive()</tt>测试)或者在类别网页(<tt>is_category()</tt>)上时,将the_content()标签替换为the_excerpt()。
 
下面的两个例子在1.5版本以及更高的版本中都能够运行。


%%% <?php if(is_category() || is_archive()) {
%%% <?php if(is_category() || is_archive()) {
第27行: 第29行:
  } ?> %%%
  } ?> %%%


For versions of WordPress prior to 1.5, only the following will work :
对于WordPress1.5之前的版本,只有下面的能够运行:


%%% <?php if($cat || $m) {
%%% <?php if($cat || $m) {
第35行: 第37行:
  } ?> %%%
  } ?> %%%


== Parameters ==
== 参数 ==


This tag has no parameters.
这个标签没有参数。


== Comparison of the_excerpt() vs. the_content() ==
== 比较 the_excerpt() the_content() ==


Sometimes is more meaningful to use only [[WordPress:Template_Tags/the_content|the_content()]] function. [[WordPress:Template_Tags/the_content|the_content()]] will decide what to display according to whether %%%<!--More-->%%% tag was used.
有时候只使用[[WordPress:Template_Tags/the_content|the_content()]]函数,更有意义。[[WordPress:Template_Tags/the_content|the_content()]]根据是否使用了
%%%<!--More-->%%%标签,来决定显示什么。


%%%<!--More-->%%% tag splits post/page into two parts: only content before tag should be displayed in listing.
%%%<!--More-->%%%标签将文章/网页分成了两个部分:只有标签之前的内容可以显示在列表上。


Remember that %%%<!--More-->%%% is (of course) ignored when showing only post/page (singles).
记住,当只显示文章/网页(单一的)的时候,(当然)忽视了%%%<!--More-->%%%


== Related ==
== 相关的==


{{Tag Post Tags}}
{{标签文章标签}}


{{No Param Tag Footer}}
{{没有Param标签页底文字}}

2008年7月18日 (五) 09:37的最新版本

描述[ ]

显示当前文章的摘录,结尾有[...],[...]并不是一个"阅读更多"链接。如果你没有提供一篇清晰明了的文章摘录(在文章编辑器的可选择的摘录区),标签会显示teaser,指的是文章内容的前55个字。同时在后一种情况下,HTML标签和图形都从摘录内容中清除了。必须在The Loop内使用这个标签。

用法[ ]

%%% <?php the_excerpt(); ?> %%%


例子[ ]

默认用法[ ]

显示文章摘录。将非单一/非permalink的文章用在一个代替品,替换the_content(),迫使摘录在Loop内显示。


<?php the_excerpt(); ?>

与条件式标签一起使用[ ]

在归档网页(由 is_archive()测试)或者在类别网页(is_category())上时,将the_content()标签替换为the_excerpt()。

下面的两个例子在1.5版本以及更高的版本中都能够运行。

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

	the_excerpt();
} else {
	the_content();
} ?> %%%

对于WordPress1.5之前的版本,只有下面的能够运行:

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

	the_excerpt();
} else {
	the_content();
} ?> %%%

参数[ ]

这个标签没有参数。

比较 the_excerpt() 和 the_content()[ ]

有时候只使用the_content()函数,更有意义。the_content()根据是否使用了 %%%%%%标签,来决定显示什么。

%%%%%%标签将文章/网页分成了两个部分:只有标签之前的内容可以显示在列表上。

记住,当只显示文章/网页(单一的)的时候,(当然)忽视了%%%%%%。

相关的[ ]

the_ID, the_title, the_title_attribute, single_post_title, the_title_rss, the_content, the_content_rss, the_excerpt, the_excerpt_rss, previous_post_link, next_post_link, posts_nav_link, the_meta,

模板:没有Param标签页底文字